220 Part I EXAM PREPARATION DATEDIFF subtracts the

220 Part I EXAM PREPARATION DATEDIFF subtracts the start date from the end date to produce the result. Look at the following example: USE pubs GO SELECT pubdate, DATEDIFF(year, pubdate, getdate()) AS . years difference FROM titles The method of counting crossed boundaries such as minutes, seconds, and milliseconds makes the result given by DATEDIFF consistent across all data types. The result is a signed integer value equal to the number of date_part boundaries crossed between the first and second date. For example, the number of weeks between Monday, March 5, and Monday, March 12, is 1. GETDATE To get the current date, use the GETDATE function. This function can be useful when you are producing reports that need to be dated. The GETDATE function returns the current system date and can be used in a SELECT statement. The syntax for GETDATE is GETDATE() The following is an example of using GETDATE() to return the current date: SELECT Getdate() as today s date You can use GETDATE in designing a report to have the current date and time printed every time the report is produced. GETDATE is also useful for functions such as logging the time a transaction occurred on an account. You can use GETDATE anywhere to return the current system date. DATENAME The DATENAME function can be used in determining the current date_part in the form of a string. You may, for instance, need to know specifically the day or month of a publication. The DATENAME function returns a character string representing the specified date part from the date. The syntax is DATENAME (date_part, date)

For high quality website hosting services please check java web hosting website.

Comments are closed.