DATEFROMPARTS –Construct a Date/Datetime with SQL Server 2012


--SQL Server 2012

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

--Samples:
SELECT DATEFROMPARTS ( 2013, 3, 31 )
SELECT DATEFROMPARTS ( 2012, 2, 29 )
SELECT DATETIMEFROMPARTS ( 2010, 12, 31, 23, 59, 59, 0 )
SELECT DATETIME2FROMPARTS ( 2011, 8, 15, 14, 23, 44, 50, 2 );



Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s