Saturday, July 11, 2009

MS SQL: Get Day/Month of Date



1.This is simple query, which gives Date
select GETDATE()
output:
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
output:
Saturday July

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


No comments:

Post a Comment