filmov
tv
Getting the current date and time in SQL Server, and using timezones with DateTimeOffset
Показать описание
In this video, we will be looking at the various functions and the differences between them to getting the current time, and using DateTimeOffset.
My SQL Server Udemy courses are:
----
My Excel for PC courses are:
----
In this video, we will be looking at the following functions, which return s a datetime, accurate to a 1/300th of a second:
CURRENT_TIMESTAMP - the ANSI SQL version.
GETDATE() - this is the SQL Server version of CURRENT_TIMESTAMP.
GETUTCDATE() - this returns the GETDATE() for UTC/GMT.
The following returns a datetime2(7), which returns up to 7 decimal places.
SYSDATETIME() - this is the equivalent of GETDATE()
SYSUTCDATETIME() - this is the equivalent of GETUTCDATE()
In addition, we will be looking at:
SYSDATETIMEOFFSET() - this returns a datetimeoffset, so it includes a timezone.
CURRENT_TIMEZONE() - this returns the timezone (in winter)
DATETIMEOFFSETFROMPARTS - this takes 10 numerical parameters, for year, month, day, hour, minute, second, fraction of a second, hour offset, minute offset, and decimal places for the fraction of a second.
TODATETIMEOFFSET - this converts a datetime to a datetimeoffset.
SWITCHOFFSET - this converts a datetimeoffset in one timezone to another timezone.
TODATETIMEOFFSET(CURRENT_TIMESTAMP, '-07:00')
SWITCHOFFSET(SYSDATETIMEOFFSET(), '-07:00')
My SQL Server Udemy courses are:
----
My Excel for PC courses are:
----
In this video, we will be looking at the following functions, which return s a datetime, accurate to a 1/300th of a second:
CURRENT_TIMESTAMP - the ANSI SQL version.
GETDATE() - this is the SQL Server version of CURRENT_TIMESTAMP.
GETUTCDATE() - this returns the GETDATE() for UTC/GMT.
The following returns a datetime2(7), which returns up to 7 decimal places.
SYSDATETIME() - this is the equivalent of GETDATE()
SYSUTCDATETIME() - this is the equivalent of GETUTCDATE()
In addition, we will be looking at:
SYSDATETIMEOFFSET() - this returns a datetimeoffset, so it includes a timezone.
CURRENT_TIMEZONE() - this returns the timezone (in winter)
DATETIMEOFFSETFROMPARTS - this takes 10 numerical parameters, for year, month, day, hour, minute, second, fraction of a second, hour offset, minute offset, and decimal places for the fraction of a second.
TODATETIMEOFFSET - this converts a datetime to a datetimeoffset.
SWITCHOFFSET - this converts a datetimeoffset in one timezone to another timezone.
TODATETIMEOFFSET(CURRENT_TIMESTAMP, '-07:00')
SWITCHOFFSET(SYSDATETIMEOFFSET(), '-07:00')
Комментарии