SQL Server Denali has made
developers life quite easy by introducing new useful functions. We have already
discussed EOMONTH() in an
early post.
DATEFROMPARTS() is a new function introduced in SQL Server Denali,
which will help us to avoid lengthy code to get date from year, month and day
inputs. DATEFROMPARTS() takes three input parameters YEAR, MONTH and DAY
and returns value in DATE format.
DATEFROMPARTS ( year, month, day )
DATEFROMPARTS() is not only function to get DATETIME values from parts but 5 other functions are also introduced.
- TIMEFROMPARTS () which returns output in TIME format.
TIMEFROMPARTS ( hour, minute, seconds, fractions, precision )
- SMALLDATETIMEFROMPARTS() which returns output in SMALLDATETIME2 format.
SMALLDATETIMEFROMPARTS ( year, month, day, hour, minute )
- DATETIMEFROMPARTS() which returns output in DATETIME format.
DATETIMEFROMPARTS ( year, month, day, hour, minute, seconds, milliseconds )
- DATETIME2FROMPARTS() which returns output in DATETIME2 format.
DATETIME2FROMPARTS ( year, month, day, hour, minute, seconds, fractions, precision )
- DATETIMEOFFSETFROMPARTS() which returns output in datetimeoffset format.
DATETIMEOFFSETFROMPARTS ( year, month, day, hour, minute, seconds, fractions, hour_offset, minute_offset, precision )
------------------------------------------------------------------------------------
Read More about SQL Server 2012 (Code Name: Denali)
No comments:
Post a Comment
All suggestions are welcome