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

SQL Server 101
SQL Server 101
12.6 هزار بار بازدید - 3 سال پیش - In this video, we will
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:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: https://rebrand.ly/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): https://rebrand.ly/database-fundamentals
70-462 SQL Server Database Administration (DBA): https://rebrand.ly/sql-server-dba
Microsoft SQL Server Reporting Services (SSRS): https://rebrand.ly/sql-server-ssrs
SQL Server Integration Services (SSIS): https://rebrand.ly/sql-server-ssis
SQL Server Analysis Services (SSAS): https://rebrand.ly/sql-server-ssas-mdx
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
----
My Excel for PC courses are:
Beginner to Excel - https://rebrand.ly/microsoft-excel-sp...
Intermediate to Expert Advanced - https://rebrand.ly/microsoft-excel-ex...
Power Table, Get and Transform and Power Pivot - https://rebrand.ly/visualizing-data-e...
VBA macros for Excel - https://rebrand.ly/excel-vba-pc
----
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')
3 سال پیش در تاریخ 1400/04/09 منتشر شده است.
12,660 بـار بازدید شده
... بیشتر