Saturday, July 11, 2009

MS SQL: Get Day/Month of Date

1.This is simple query, which gives Date
select GETDATE()
2009-07-11 19:56:18.543

2.This query give day and month
select DATENAME(dw,GETDATE()) as Day, DATENAME(mm,GETDATE()) as Month
Saturday July

3:This query gives individual date, month, year
select DAY(GETDATE()) as Date,MONTH(GETDATE()) as Month,YEAR(GETDATE()) as Year
11 7 2009

No comments:

Post a Comment