Home » SQL Server » New built-in Date and time functions in SQL Server 2012……..Part 3 of 5

New built-in Date and time functions in SQL Server 2012……..Part 3 of 5

Microsoft SQL Server 2012 introduces 14 new built-in functions. 7 Out 14 explained below.

Date and time functions

· DATEFROMPARTS : DATEFROMPARTS returns a date value with the date portion set to the specified year, month and day, and the time portion set to the default. If the arguments are not valid, then an error is raised. If required arguments are null, then null is returned.

DATEFROMPARTS ( year, month, day )

· DATETIMEFROMPARTS : DATETIMEFROMPARTS returns a datetime value. If the arguments are not valid, then an error is raised. If required arguments are null, then a null is returned.

DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )

· DATETIME2FROMPARTS : DATETIME2FROMPARTS returns a datetime2 value. If the arguments are not valid, an error is raised. If required arguments are null, then null is returned. However, if the precision argument is null, then an error is raised.

DATETIME2FROMPARTS ( year, month, day, hour, minute, seconds, fractions, precision )

· SMALLDATETIMEFROMPARTS : SMALLDATETIMEFROMPARTS returns a smalldatetime value. If the arguments are not valid, then an error is thrown. If required arguments are null, then null is returned.

SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute )

· DATETIMEOFFSETFROMPARTS : DATETIMEOFFSETFROMPARTS returns a datetimeoffset data type. The offset arguments are used to represent the time zone offset. If the offset arguments are omitted, then the time zone offset is assumed to be 00:00, that is, there is no time zone offset. If the offset arguments are specified, then both arguments must be present and both must be positive or negative. If minute_offset is specified without hour_offset, an error is raised. If other arguments are not valid, then an error is raised. If required arguments are null, then a null is returned. However, if the precision argument is null, then an error is raised.

DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision )

· TIMEFROMPARTS : TIME returns a time value. If the arguments are invalid, then an error is raised. If any of the parameters are null, null is returned. However, if the precision argument is null, then an error is raised.

 TIMEFROMPARTS ( hour, minute, seconds, fractions, precision )

· EOMONTH : EOMONTH Returns the last day of the month that contains the specified date.

EOMONTH ( start_date [, month_to_add ] )

Leave a Reply

Join us on Facebook

microsoftcommunitycontributor
%d bloggers like this: