New DATETIME functions in Denali

New DateTime  Function in Denali

    This will return last day for the month from the date at specified offset
    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
SELECT Eomonth(Getdate()) last_day_of_month


    with offset
    select eomonth (getdate(), 1) last_day_next_month, eomonth(getdate(),-1) last_day_prev_month


Returns day from specified value of year,  month, day

DATEFROMPARTS ( year, month, day )


SELECT Datefromparts (2011, 09, 01)


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

Popular Posts