Getting the current date and time in SQL Server, and using timezones with DateTimeOffset

  Рет қаралды 13,068

SQL Server 101

SQL Server 101

Күн бұрын

Пікірлер: 9
@alihojati-gc4nk
@alihojati-gc4nk 8 ай бұрын
عالی بود😊
@MegaVivek1992
@MegaVivek1992 2 жыл бұрын
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?
@SQLServer101
@SQLServer101 2 жыл бұрын
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-View
@Mr-360-View 2 жыл бұрын
How to show database stored date time to user's current timezone
@Daniel-yt6ls
@Daniel-yt6ls 3 жыл бұрын
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?
@SQLServer101
@SQLServer101 3 жыл бұрын
Hi Daniel. You are probably using the wrong timezone structure. It is very strict. Use '-02:00'. Phillip
@Daniel-yt6ls
@Daniel-yt6ls 3 жыл бұрын
@@SQLServer101 Thank you, it worked.
@pavan393
@pavan393 2 жыл бұрын
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';
@SQLServer101
@SQLServer101 2 жыл бұрын
Hi Pavan. Yes, you can. Phillip
Replacing text in SQL Server: REPLACE, STUFF and TRANSLATE
8:35
SQL Server 101
Рет қаралды 12 М.
SQL tutorial | Date Functions | Difference between DATEDIFF and DATEADD
19:25
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
DateTimeOffset vs DateTime - Which One To Use? (C# .NET)
9:36
Gui Ferreira
Рет қаралды 10 М.
Just store UTC? Handling Time Zones & Daylight Saving
7:44
CodeOpinion
Рет қаралды 34 М.
Handling Time Zones and Daylight Saving Time in SQL Server
4:13
Bert Wagner
Рет қаралды 10 М.
Database vs Data Warehouse vs Data Lake | What is the Difference?
5:22
Alex The Analyst
Рет қаралды 837 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН