I have a datetime column in a table which is in GMT.
I'm trying to convert this using the AT TIME ZONE
function to PST. I can do this but I need the result to be as datetime
only not with the datetimeoffset
.
SELECT MyTableMyDateColumn AT TIME ZONE 'GMT Standard Time' AT TIME ZONE 'Pacific Standard Time' AS 'OrderDate'
FROM MyTable;
I've tried format
as below as well:
SELECT FORMAT(MyTableMyDateColumn , 'MM-dd-yyyy HH:mm:ss') at TIME ZONE 'GMT Standard Time' at TIME ZONE 'Pacific Standard Time'
FROM MyTable
Appreciate all pointers and suggestions
1条答案
按热度按时间cyvaqqii1#
A simple cast to datetime should do the trick.
Create and populate sample table (Please save us this step in your future questions):
The query:
Results:
See a live demo on db<>fiddle