Monday, June 4, 2007

SQL Dateparts and Abbreviations

Table below lists the dateparts and abbreviations recognized by Microsoft SQL Server(MS SQL).
Datepart below is suitable using in DATEADD, DATEDIFF, DATENAME and all Date related function.

DatepartAbbreviations
Yearyy, yyyy
quarterqq, q
Monthmm, m
dayofyeardy, y
Daydd, d
Weekwk, ww
Hourhh
minutemi, n
secondss, s
millisecondms

3 comments:

dinesh said...

select ,DATEADD(DD, -2, GETDATE()),112) from emp ...what is usee of -2 in above query can u expalin ???

dinesh said...

plz give solution

Pradeep Kumar Shaw said...

select DATEADD(DD, -2, GETDATE())

in this -2 is giving 2 days before date of present date.