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

  Рет қаралды 12,978

SQL Server 101

SQL Server 101

Күн бұрын

Пікірлер: 9
@alihojati-gc4nk
@alihojati-gc4nk 7 ай бұрын
عالی بود😊
@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 М.
DatePart, DateAdd and DateDiff functions in SQL Server   Part 27
21:29
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 16 МЛН
МЕНЯ УКУСИЛ ПАУК #shorts
00:23
Паша Осадчий
Рет қаралды 4 МЛН
World’s strongest WOMAN vs regular GIRLS
00:56
A4
Рет қаралды 41 МЛН
Real Man relocate to Remote Controlled Car 👨🏻➡️🚙🕹️ #builderc
00:24
SQL tutorial | Date Functions | Difference between DATEDIFF and DATEADD
19:25
Searching for text in SQL Server: CHARINDEX and PATINDEX
11:01
SQL Server 101
Рет қаралды 22 М.
The Problem with Time & Timezones - Computerphile
10:13
Computerphile
Рет қаралды 4 МЛН
Just store UTC? Handling Time Zones & Daylight Saving
7:44
CodeOpinion
Рет қаралды 33 М.
DateTimeOffset vs DateTime - Which One To Use? (C# .NET)
9:36
Gui Ferreira
Рет қаралды 9 М.
The RIGHT way to deal with Date and Time in C#
8:31
Nick Chapsas
Рет қаралды 65 М.
PIZZA or CHICKEN // Left or Right Challenge
00:18
Hungry FAM
Рет қаралды 16 МЛН