DATETIME2FROMPARTS function – SQL Server Denali

Written by VidhyaSagar. Posted in General

We have one more new date time function in Denali. DATETIME2FROMPARTS is the function name which is used to returns datetime2 value for the input value given.  If the arguments are not valid then an error is raised or if the argument is NULL then it will return a NULL value. This function is to precise, not sure how frequently we will use this function to get datetime2 value.

Syntax is below

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

Lets try it with example

SELECT DATETIME2FROMPARTS(2011,09,02,23,55,9,5664,4)

datetime2fromparts

VN:F [1.9.17_1161]
Rating: 4.5/5 (2 votes cast)
VN:F [1.9.17_1161]
Rating: +1 (from 1 vote)
DATETIME2FROMPARTS function - SQL Server Denali, 4.5 out of 5 based on 2 ratings

Tags: , , , ,

Trackback from your site.

Leave a comment

*

Recent Comments

Amit Bhatt

|

Hi Deepak,

Thanks for such a nice article.

You missed one thing to add in code:
@article = ‘all’,

Hence the script will be like this:
EXEC sp_addsubscription
@publication = ‘mypublication’,
@article = ‘ALL’,
@subscriber = ‘Subscriberservername’,
@destination_db = ‘mydestinationdbname’,
@reserved=’Internal’

Error 18486 | Platformblog

|

[...] SQL-Articles » Troubleshooting Login failed Error 18456This is one of the infamous error message (and number) that most of the DBAs …. 18486. Login failed for user ‘%.*ls’ because the account is currently locked out. [...]

VidhyaSagar

|

Naveen,
I’ll check this out and get back to you.

balakiran

|

Thanks man, Very simple & easy to understand !!!!