0

I need to convert the time from GMT format to AEST (Australia) and also take care of the daylight saving properly.

Any idea or help will be appreciated.

Thanks Shadab

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Shadab
  • 11
  • 2

2 Answers2

0

MySQL provides a CONVERT_TZ function. For this to work, the time_zone% tables have to be populated.

There's no need for me to repeat the MySQL documentation.

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_convert-tz

spencer7593
  • 106,611
  • 15
  • 112
  • 140
0

In SQL Server 2008 and newer, you can use the DATETIMEOFFSET datatype for date/time values including a time zone.

There's also a TODATETIMEOFFSET function that converts a UTC time to a timezone-based date/time.

So in your case, you could convert the UTC date/time to AEST date/time like this:

DECLARE @todaysDateTime datetime2;
SET @todaysDateTime = SYSUTCDATETIME();

SELECT 
    TODATETIMEOFFSET (@todaysDateTime, '+10:00'); -- AEST date/time

What I don't really know is whether there's anything to automagically handle daylight savings settings - you might need to handle that yourself, by defining the timezone offset (+10:00 for AEST, +11:00 for AEDT, depending on the date in the year).

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459