New DateTime Function in Denali
1. EOMONTH
This will return last day for the month from the date at specified offset
syntax
EOMONTH ( start_date [, month_to_add ] )
StartDate :- Date from which we want to get last day of month at offset
Offset:- Specifying number of months to add. Default is 0
Example
with offset
select eomonth (getdate(), 1) last_day_next_month, eomonth(getdate(),-1) last_day_prev_month
2.DATEFROMPARTS
Returns day from specified value of year, month, day
DATEFROMPARTS ( year, month, day )
Example
3.TIMEFROMPARTS
Returns a time from specified time paratmeters
TIMEFROMPARTS ( hour, minute, seconds, fractions, precision )
Precision shows part of second
if its 7 its shows nano second , if its 3 it shows millisecond
Fraction is depending on precision.its length should be in range of precision
With specifying fraction
1. EOMONTH
This will return last day for the month from the date at specified offset
syntax
EOMONTH ( start_date [, month_to_add ] )
StartDate :- Date from which we want to get last day of month at offset
Offset:- Specifying number of months to add. Default is 0
Example
SELECT Eomonth(Getdate()) last_day_of_month
with offset
select eomonth (getdate(), 1) last_day_next_month, eomonth(getdate(),-1) last_day_prev_month
2.DATEFROMPARTS
Returns day from specified value of year, month, day
DATEFROMPARTS ( year, month, day )
Example
SELECT
Datefromparts (2011, 09, 01)
3.TIMEFROMPARTS
Returns a time from specified time paratmeters
TIMEFROMPARTS ( hour, minute, seconds, fractions, precision )
Precision shows part of second
if its 7 its shows nano second , if its 3 it shows millisecond
Fraction is depending on precision.its length should be in range of precision
SELECT
Timefromparts (10, 10, 10, 0, 0) AS time
With specifying fraction
SELECT
TIMEFROMPARTS (
10, 10, 10, 1, 7 ) AS Result
No comments:
Post a Comment