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.

DAY<br />

The DAY function returns an integer representing the day part of the specified date. The syntax is as follows:<br />

DAY()<br />

The DAY function is equivalent to DATEPART(dd, ).<br />

GETDATE<br />

The GETDATE function returns the current system date and time. The syntax is as follows:<br />

GETDATE()<br />

GETUTCDATE<br />

The GETUTCDATE function returns the current UTC (Universal Time Coordinate) time. In other words,<br />

this returns GMT (Greenwich Mean Time). The value is derived by taking the local time from the server,<br />

and the local time zone, and calculating GMT from this. Daylight saving is included. GETUTCDATE cannot<br />

be called from a user-defined function. The syntax is as follows:<br />

ISDATE<br />

GETUTCDATE()<br />

The ISDATE function determines whether an input expression is a valid date. The syntax is as follows:<br />

MONTH<br />

ISDATE()<br />

The MONTH function returns an integer that represents the month part of the specified date. The syntax is<br />

as follows:<br />

MONTH()<br />

The MONTH function is equivalent to DATEPART(mm, ).<br />

SYSDATETIME<br />

Much like the more venerable GETDATE function, SYSDATETIME returns the current system date and<br />

time. The differences are twofold: First, SYSDATETIME returns a higher level of precision. Second, the<br />

newer function returns the newer datetime2 data type (to support the higher precision — a precision<br />

of 7 in this case). The syntax is as follows:<br />

SYSDATETIME()<br />

Apendix A: System Functions<br />

607

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

Saved successfully!

Ooh no, something went wrong!