DATE PART FUNCTIONS
This is used, when we need a part of date or time from a date time variable.
We can use DATEPART() method only with select
command.
Example:
SELECT DATEPART(year, GETDATE()) AS 'Year'
Output:
Year
2012
Year
2012
SELECT DATEPART(month, GETDATE()) AS 'Month'
Output:
Month
7
7
SELECT DATEPART(hour, GETDATE()) AS 'Hour'
Output:
Hour
15
15
Back |
No comments :
Post a Comment