Download presentation
Presentation is loading. Please wait.
1
Trainer: Bach Ngoc Toan– TEDU Website: http://tedu.com.vn
Lesson 38 SQL Working With Dates Trainer: Bach Ngoc Toan– TEDU Website:
2
SQL Dates The most difficult part when working with dates is to be sure that the format of the date you are trying to insert, matches the format of the date column in the database.
3
SQL Date Data Types SQL Server comes with the following data types for storing a date or a date/time value in the database: DATE - format YYYY-MM-DD DATETIME - format: YYYY-MM-DD HH:MI:SS SMALLDATETIME - format: YYYY-MM-DD HH:MI:SS TIMESTAMP - format: a unique number
4
SQL Working with Dates You can compare two dates easily if there is no time component involved!
5
SQL Server Date Functions
CURRENT_TIMESTAMP Returns the current date and time DATEADD Returns a date after a certain time/date interval has been added DATEDIFF Returns the difference between two date values, based on the interval specified DATENAME Returns a specified part of a given date, as a string value DATEPART Returns a specified part of a given date, as an integer value DAY Returns the day of the month (from 1 to 31) for a given date GETDATE GETUTCDATE Returns the current UTC date and time MONTH Returns the month (from 1 to 12) for a given date YEAR Returns the year (as a four-digit number) for a given date
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.