sql server offers us a few functions when working with time, in this article I am going to explain the functions that we can use to get date and time parts. The functions that we have are:
DATEFROMPARTS
SMALLDATETIMEFROMPARTS
DATETIMEFROMPARTS
DATETIME2FROMPARTS
DATETIMEOFFSETFROMPARTS
TIMEFROMPARTS
DATENAME
DATEPART
EOMONTH
1 2 3 4 5 6 7 8 9 |
set dateformat dmy; declare @date as date set @date = '06/08/2019' select DATEPART(month, @date) select DATEFROMPARTS(2019,8,19) select DATENAME(month, @date) select eomonth(sysdatetime()) |