-1

how can we convert the GMT to local SQL DATE? When i store GMT time , then 1 hour is subtracted from this value. please help me.

shyamji
  • 37
  • 1
  • 7
  • 2
    Possible duplicate of [SQL Server 2008 - How to convert GMT(UTC) datetime to local datetime?](https://stackoverflow.com/questions/6064674/sql-server-2008-how-to-convert-gmtutc-datetime-to-local-datetime) – chevybow Jun 11 '18 at 20:29

1 Answers1

0

Your question is a bit ambiguous as written, but I am guessing that you want to convert a UTC datetime (sometimes called GMT or Zulu time) into a datetime in your local timezone.

You indicate that your local time zone is -1 hour offset from UTC time.

In this case you simply use the DATEADD function:

SET MyTimeLocal = DATEADD(HH, -1, MyTimeGMT)

Note that this will only work so long as your time zone really is one hour before UTC time. If your location uses daylight saving time, this will be wrong as soon as the time changes, and it will be extra wrong when the time to be converted falls in the crack of the clock change.

There are many better ways to do this in general, but to give a general solution we would need to know what version of SQL is being used and what exactly you are trying to accomplish.

Craig.Feied
  • 2,617
  • 2
  • 16
  • 25