TOPIC | TEXT | SYNTAX | Example |
---|---|---|---|
CURRENT_DATE | Returns the current date. | { CURRENT_DATE [ () ] | CURDATE() | SYSDATE | TODAY } | |
CURRENT_TIME | Returns the current time. | { CURRENT_TIME [ () ] | CURTIME() } | |
CURRENT_TIMESTAMP | Returns the current timestamp. | { CURRENT_TIMESTAMP [ ( [ int ] ) ] | NOW( [ int ] ) } | |
DATEADD | Adds units to a timestamp. | DATEADD(unitString, addInt, timestamp) | |
DATEDIFF | Returns the the number of crossed unit boundaries between two timestamps. | { DATEDIFF | TIMESTAMPDIFF } (unitString, aTimestamp, bTimestamp) | |
DAYNAME | Returns the name of the day (in English). | DAYNAME(date) | |
DAY_OF_MONTH | Returns the day of the month (1-31). | DAY_OF_MONTH(date) | |
DAY_OF_WEEK | Returns the day of the week (1 means Sunday). | DAY_OF_WEEK(date) | |
DAY_OF_YEAR | Returns the day of the year (1-366). | DAY_OF_YEAR(date) | |
EXTRACT | Returns 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 ) | |
FORMATDATETIME | Formats a date, time or timestamp as a string. | FORMATDATETIME ( timestamp, formatString [ , localeString [ , timeZoneString ] ] ) | |
HOUR | Returns the hour (0-23) from a timestamp. | HOUR(timestamp) | |
MINUTE | Returns the minute (0-59) from a timestamp. | MINUTE(timestamp) | |
MONTH | Returns the month (1-12) from a timestamp. | MONTH(timestamp) | |
MONTHNAME | Returns the name of the month (in English). | MONTHNAME(date) | |
PARSEDATETIME | Parses a string and returns a timestamp. | PARSEDATETIME(string, formatString [, localeString [, timeZoneString]]) | |
QUARTER | Returns the quarter (1-4) from a timestamp. | QUARTER(timestamp) | |
SECOND | Returns the second (0-59) from a timestamp. | SECOND(timestamp) | |
WEEK | Returns the week (1-53) from a timestamp. | WEEK(timestamp) | |
YEAR | Returns the year from a timestamp. | YEAR(timestamp) |
SQL basics- complete reference guide - part7 - Date Time Functions
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment
Your Comment and Question will help to make this blog better...