What is this Site!!

All about Real time requirements in Orale Stay Tune!!
Showing posts with label Date Functions. Show all posts
Showing posts with label Date Functions. Show all posts

Thursday, February 7, 2008

SQL Server


Date Functions

Select date_function(parameter)


1. Dateadd (datepart,number,date): Adds the number of dateparts to the date Example

Select Dateadd (mm, 6, '1/1/01')-[ 2001-07-01] Select Dateadd (mm, -6, '1/1/01')-[ 2001-07-01]


2. Datediff (datepart,date1,date2): Number of dateparts between two dates Example

Select datediff(dd, '10/3/01', '10/9/01')


3. Getdate() :Returns current date and time in internal format Example

Select Getdate()




Datepart

Abbreviation

Day

DD,D

Day of year

DY

Hour

HH

Millisecond

MS

Minute

MI

Month

MM,M

Quarter

QQ

Second

SS, S

Week

WK

Weekday

DW

Year

YY, YYYY