Today I’m going to give you a short demo on the new date time function in SQL Server Denali. It’s SMALLDATETIMEFROMPARTS function, are you able to get the things from naming convention. Yep! you are right, this function will return small datetime value with the parts of data being supplied to the function. I hope previously we did this with convert or cast function.
Syntax is below
SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute )
Lets do a try
SELECT SMALLDATETIMEFROMPARTS ( 2055, 08, 12, 12, 53 )
If you provide invalid arguments then error will be thrown. Lets say if you provide a value greater than 12 in month argument then it will fail to construct the smalldatetime value
Leave a Reply