-1

How to convert given UTC date time to PST date time, by keeping the daylight stuff in time calculations?

Note that the server I am hitting is in utc. I mean, GETDATE() = GETUTCDATE().

Also, we can't use AT TIME ZONE, as DB is on older SQL Server.

Thanks in advance for the help.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
RaturiMic
  • 73
  • 1
  • 8
  • What version of SQL exactly? What makes you think we can suggest correct syntax if we don't know what version you are on? – Nick.Mc Nov 08 '18 at 23:20
  • sorry it was sql server 2014 – RaturiMic Nov 08 '18 at 23:49
  • 1
    Possible duplicate of [Convert Datetime column from UTC to local time in select statement](https://stackoverflow.com/questions/8038744/convert-datetime-column-from-utc-to-local-time-in-select-statement) –  Nov 09 '18 at 00:15

1 Answers1

1

Search the site, example: Convert Datetime column from UTC to local time in select statement

Read the link above, also include daylight stuff in there for some of the responses too.

Noogen
  • 1,652
  • 12
  • 13
  • copied the query from @Aiden Kaskela : select CONVERT(datetime, SWITCHOFFSET(yourdate, DATEPART(TZOFFSET, yourdate AT TIME ZONE 'Pacific Standard Time'))) – RaturiMic Nov 08 '18 at 23:51