DATEADD function page 1 |
||||||||||||||||||||||||||||
The function DATEADD ( datepart , number, date ) returns a datetime data type value based on adding a number of intervals (integer) of the datepart type to the specified date. For example, we can add to the specified date any number of years, days, hours, minutes etc. The table from Электронная документация SQL Server Books OnlineBOL (SQL Server — Books On Line) lists the dateparts and abbreviations.
If you wish to know, which day will be after a week from today, you can write: orWe'll get the same result within the elapse time between running the queries. But we cannot write in that case as follows We can also use the T-SQL (Transact-SQL) is Microsoft`s and Sybase`s proprietary procedural extension to SQL.T-SQL GETDATE() function instead of CURRENT_TIMESTAMP. Example 7.1.1 Find the day through a week after the last flight.
Notes:
In examples of the given chapter the database "Aeroflot" is used. The description of this scheme (and all other schemes which are used on the site for the solving of exercises) you can find in the Appendix 1.
Usage of subquery as an argument is allowed, for that subquery returns a single value of datetime type. Suggested exercises: 94
|