SQL basics- complete reference guide - part7 - Date Time Functions

Part7: SQL Date Time Functions Reference

TOPICTEXTSYNTAXExample
CURRENT_DATEReturns the current date.{ CURRENT_DATE [ () ] | CURDATE() | SYSDATE | TODAY }
CURRENT_TIMEReturns the current time.{ CURRENT_TIME [ () ] | CURTIME() }
CURRENT_TIMESTAMPReturns the current timestamp.{ CURRENT_TIMESTAMP [ ( [ int ] ) ] | NOW( [ int ] ) }
DATEADDAdds units to a timestamp.DATEADD(unitString, addInt, timestamp)
DATEDIFFReturns the the number of crossed unit boundaries between two timestamps.{ DATEDIFF | TIMESTAMPDIFF } (unitString, aTimestamp, bTimestamp)
DAYNAMEReturns the name of the day (in English).DAYNAME(date)
DAY_OF_MONTHReturns the day of the month (1-31).DAY_OF_MONTH(date)
DAY_OF_WEEKReturns the day of the week (1 means Sunday).DAY_OF_WEEK(date)
DAY_OF_YEARReturns the day of the year (1-366).DAY_OF_YEAR(date)
EXTRACTReturns a specific value from a timestamps.EXTRACT ( { YEAR | YY | MONTH | MM | DAY | DD | DAY_OF_YEAR
    | DOY | HOUR | HH | MINUTE | MI | SECOND | SS | MILLISECOND | MS }
    FROM timestamp )
FORMATDATETIMEFormats a date, time or timestamp as a string.FORMATDATETIME ( timestamp, formatString
[ , localeString [ , timeZoneString ] ] )
HOURReturns the hour (0-23) from a timestamp.HOUR(timestamp)
MINUTEReturns the minute (0-59) from a timestamp.MINUTE(timestamp)
MONTHReturns the month (1-12) from a timestamp.MONTH(timestamp)
MONTHNAMEReturns the name of the month (in English).MONTHNAME(date)
PARSEDATETIMEParses a string and returns a timestamp.PARSEDATETIME(string, formatString
[, localeString [, timeZoneString]])
QUARTERReturns the quarter (1-4) from a timestamp.QUARTER(timestamp)
SECONDReturns the second (0-59) from a timestamp.SECOND(timestamp)
WEEKReturns the week (1-53) from a timestamp.WEEK(timestamp)
YEARReturns the year from a timestamp.YEAR(timestamp)

No comments :

Post a Comment

Your Comment and Question will help to make this blog better...