These functions perform an operation on a date and time input value and return a string, numeric, or date and time value.
GETDATE (): Returns the current system date and time in the SQL Server standard internal format for date time values.
Ex: Select GETDATE () ------- 2014-02-15 15:35:22.670
DAY (): Returns an integer representing the day date part of the specified date.
Ex: Select DAY (get date ())
MONTH (): Returns an integer that represents the month part of a specified date.
Ex: Select MONTH (get date ())
YEAR (): Returns an integer that represents the year part of a specified date.
Ex: Select YEAR (get Date ())
GETUTCDATE (): Returns the date time value representing the current UTC
time (Coordinated Universal Time).
Ex: Select GETUTCDATE ();
DATE NAME (): Returns a character string representing the specified date part of the specified date.
Ex: Select DATE NAME (DW, get date ())
DATE PART (): Returns an integer representing the specified date part of the specified date.
Ex: Select DATEPART (DD, get date ())
DATE ADD (): Returns a new date time value based on adding an interval to the specified date.
Ex: Select DATEADD (DD, 5, get date ())
DATE DIFF (): Returns the difference between the start and end dates in the give date part format.
Ex: Select DATEDIFF (MM, ‘2012-12-15’, get date ())
0 comments:
Post a Comment