select getdate() --current date
select getdate()-1 --previous date from current date
select DATEADD(dd,5,getdate()) -- after 5 days from current
select DATEADD(dd,-5,getdate()) -- before 5 days from current
select DATEDIFF(dd,getdate()-5,GETDATE()) -- difference of two dates
---------------------
select DATEPART (yy, getdate()) -- year
select DATEPART (qq, getdate()) -- quarter
select DATEPART (mm, getdate()) -- month
select DATEPART (dy, getdate()) -- day of year
select DATEPART (dd, getdate()) -- days
select DATEPART (wk, getdate()) -- week
select DATEPART (dw, getdate()) -- week day
select DATEPART (hh, getdate()) -- hour
select DATEPART (mi, getdate()) -- minute
select DATEPART (ss, getdate()) -- sec
select DATEPART (ms, getdate()) -- miliseconds
select DATENAME (mm, getdate()) -- return month name like March
select DATENAME (dw, getdate()) -- return week day like Thursday
select ISDATE (getdate()) -- return 1(true) or false (0)
select DAY(getdate()) -- return day in integer
select MONTH(getdate()) -- return month in integer
select YEAR(getdate()) -- return year in integer
No comments:
Post a Comment