Search this blog

Tuesday, June 2, 2009

First Day Of Month thru SQL Query

Use this Query to get First day of a Month,

SELECT DATENAME(dw, DATEADD(dd, - DATEPART(dd, GETDATE()) + 1, GETDATE())) AS FirstDay


In this Query, We used dw which is the abbreviations of weekday.

To Know, other abbreviations
-----------------------------------
Datepart - Abbreviations
-----------------------------------

year - yy, yyyy

quarter - qq, q

month - mm, m

dayofyear - dy, y

day - dd, d

week - wk, ww

weekday - dw

hour - hh

minute - mi, n

second - ss, s

millisecond - ms

-----------------------------------

No comments:

Post a Comment