Saturday, January 8, 2011

Add datepart to Existing date in SQL using Dateadd function

Select dateadd(day,21,existing_date_column)

From table.





Above query add 21 days to existing_date_column and display its result.



You can also add

Year,

quarter,

Month,

dayofyear,

Day,

Week,

Hour,

minute,

second,

millisecond





ex.

Select dateadd(year,1,existing_date_column)

From table.





It will add 1 year in existing_date

No comments:

Post a Comment