How do I specify date literal when writing SQL query from SQL Server that is linked to Oracle?

I prefer the ODBC format: –DateTime SELECT {ts’2015-09-20 12:30:00′} –Time (however this comes with “today”-time) SELECT {t’12:30:00′} –Date SELECT {d’2015-09-20′} GO The simple date literal is not culture independent… SET LANGUAGE ENGLISH; SELECT CAST(‘2014-09-13’ AS DATETIME); GO SET LANGUAGE GERMAN; SELECT CAST(‘2014-09-13’ AS DATETIME);–ERROR: there’s no month “13” GO But it works – however – … Read more

Using DateFormatter on a Unix timestamp

You can convert unixTimestamp to date using Date(timeIntervalSince1970:). let unixTimestamp = 1480134638.0 let date = Date(timeIntervalSince1970: unixTimestamp) If you want to display date in string with specific formate than you can use DateFormatter like this way. let date = Date(timeIntervalSince1970: unixtimeInterval) let dateFormatter = DateFormatter() dateFormatter.timeZone = TimeZone(abbreviation: “GMT”) //Set timezone that you want dateFormatter.locale … Read more

datetime to string with time zone

Use the “zzz” format specifier to get the UTC offset. For example: var dt = new DateTime(2010, 1, 1, 1, 1, 1, DateTimeKind.Utc); string s = dt.ToLocalTime().ToString(“yyyy-MM-dd HH:mm:ss \”GMT\”zzz”); Console.WriteLine(s); Output: 2009-12-31 19:01:01 GMT-06:00 I’m in the CDT timezone. Make sure the DateTime is unambiguously DateTimeKind.Utc.

Java Convert GMT/UTC to Local time doesn’t work as expected

I also recommend using Joda as mentioned before. Solving your problem using standard Java Date objects only can be done as follows: // **** YOUR CODE **** BEGIN **** long ts = System.currentTimeMillis(); Date localTime = new Date(ts); String format = “yyyy/MM/dd HH:mm:ss”; SimpleDateFormat sdf = new SimpleDateFormat(format); // Convert Local Time to UTC (Works … Read more

Parse date in MySQL

You may want to use the STR_TO_DATE() function. It’s the inverse of the DATE_FORMAT() function. STR_TO_DATE(str,format) This is the inverse of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns a DATETIME value if the format string contains both date and time parts, or a DATE or TIME value … Read more

Convert string to date in my iPhone app

Take a look at the class reference for NSDateFormatter. You use it like this: NSString *dateStr = @”Tue, 25 May 2010 12:53:58 +0000″; // Convert string to date object NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@”EE, d LLLL yyyy HH:mm:ss Z”]; NSDate *date = [dateFormat dateFromString:dateStr]; [dateFormat release]; For more information on how to … Read more