In this video, we will be retrieving only part of a date or time from a datetime.
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
----
If you want to retrieve the Day, Month or Year from a date field, then you can use the DAY, MONTH and YEAR functions. However, there isn't an HOUR function.
Instead, you can use the DATENAME and DATEPART functions to do the same thing. DATENAME retrieves a string, such as 'April', whereas DATEPART retrieves an int, such as 4. Using these functions, you can then get any element of a date.
However, there are some quirks that you should know, especially when you are getting the WEEK from a date. You can specify which is the first day of a week by using SET DATEFIRST.
Watch video Extract parts of dates - using DATENAME, DATEPART, DAY, MONTH and YEAR functions in SQL Server online, duration hours minute second in high quality that is uploaded to the channel SQL Server 101 09 June 2021. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 11,220 times and liked it 87 visitors.