Sunday, September 2, 2018

Date Function : DATEFROMPARTS() and TIMEFROMPARTS()


DATEFROMPARTS()

It returns the date value on specified year, month and day value.
It available in SQL Server 2012.

Syntax:

DATEFROMPARTS ( year, month, day )

Example:

SELECT DATEFROMPARTS(2010,10,30) AS DATEPARTS


OutPut:
DATEPARTS
2010-10-30

TIMEFROMPARTS()

It returns the full time on specified hour, minute and second.
It available in SQL Server 2012

Syntax:

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

Example:

SELECT TIMEFROMPARTS(10,23,45,123,3) AS TIMEPARTS


OutPut:

TIMEPARTS

10:23:45.123


SELECT TIMEFROMPARTS(10,23,45,123,4) AS TIMEPARTS


OutPut:

TIMEPARTS


10:23:45.0123

No comments:

Post a Comment