17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix A: System Functions<br />

CURRENT_TIMESTAMP<br />

The CURRENT_TIMESTAMP function simply returns the current date and time as a datetime type. It is<br />

equivalent to GETDATE(). The syntax is as follows:<br />

CURRENT_TIMESTAMP<br />

DATEADD<br />

The DATEADD function adds an interval to a date and returns a new date. The syntax is as follows:<br />

DATEADD(, , )<br />

The datepart argument specifies the time scale of the interval (day, week, month, and so on) and may<br />

be any of the dateparts recognized by <strong>SQL</strong> <strong>Server</strong>. The number argument is the number of dateparts that<br />

should be added to the date.<br />

DATEDIFF<br />

The DATEDIFF function returns the difference between two specified dates in a specified unit of time (for<br />

example: hours, days, weeks). The syntax is as follows:<br />

DATEDIFF(, , )<br />

The datepart argument may be any of the dateparts recognized by <strong>SQL</strong> <strong>Server</strong> and specifies the unit of<br />

time to be used.<br />

DATENAME<br />

The DATENAME function returns a string representing the name of the specified datepart (for example:<br />

1999, Thursday, July) of the specified date. The syntax is as follows:<br />

DATENAME(, )<br />

DATEPART<br />

606<br />

The DATEPART function returns an integer that represents the specified datepart of the specified date.<br />

The syntax is as follows:<br />

DATEPART(, )<br />

The DAY function is equivalent to DATEPART(dd, ); MONTH is equivalent to DATEPART(mm,<br />

); YEAR is equivalent to DATEPART(yy, ).

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!