I also live in UK, I’m facing lot of issues using the in my synapse datawarehouse, I felt you explained it well but still the confusion with UTC timezone is not clear for me. Which function out of these gives me the correct time whether its day light savings or normal?
@SQLServer1012 жыл бұрын
Hi MegaVivek. It depends what "the correct time" is. If you mean "the time in the UK", then you could use SELECT CURRENT_TIMESTAMP AT TIME ZONE 'GMT Standard Time'; However, I would be careful of that. When the clocks go back, then there were 2 identical hours using this calculation. Personally, I would stick to using UTC, and then convert into local time. Phillip
@Mr-360-View2 жыл бұрын
How to show database stored date time to user's current timezone
@Daniel-yt6ls3 жыл бұрын
Hello, I have a problem with my timezones in MS SQL. My sysdatetime is set correctly, but when I fetch the data, it seems that I get the time from sysutcdatetime, which is -2 hours. I tried to change it with switchoffset but I get an error: the timezone provided to builtin function switchoffset is invalid. Could you help me, please?
@SQLServer1013 жыл бұрын
Hi Daniel. You are probably using the wrong timezone structure. It is very strict. Use '-02:00'. Phillip
@Daniel-yt6ls3 жыл бұрын
@@SQLServer101 Thank you, it worked.
@pavan3932 жыл бұрын
Hi Phillip, Thanks for your great efforts in making such tutorials , can we user this query so that we can get all the Date and Time functions in a single row. select CURRENT_TIMESTAMP 'CURRENT_TIMESTAMP', GETDATE() 'GETDATE', GETUTCDATE() 'GETUTCDATE', SYSDATETIME() 'SYSDATETIME', SYSUTCDATETIME()'SYSUTCDATETIME', SYSDATETIMEOFFSET() 'SYSDATETIMEOFFSET', CURRENT_TIMEZONE() 'CURRENT_TIMEZONE', DATETIMEOFFSETFROMPARTS(2025,02,03,14,25,35,123,1,0,3) 'DATETIMEOFFSETFROMPARTS';