NOW()
Returns the current date and time.
Description
NOW returns the current date and time as a timestamp, based on the
database server's clock. Unlike most functions, it doesn't take any input
from your tables, it simply reports what moment it is when the query runs.
Syntax
NOW()Parameters
NOW takes no parameters. It's always called with empty parentheses:
NOW().
Return Type
NOW returns a TIMESTAMP value, which includes both the date and the
time of day.
Examples
Loading database engine...
Loading database engine...
NOW() changes every time you run it
Because NOW() reflects the current moment, its output is different every
time you execute the query, and it isn't tied to any data in your sample
tables. That's why these examples run it on its own rather than joining it
against employees data, joining it against a static hire_date wouldn't
produce a meaningful or repeatable result.
Common Mistakes
- Expecting
NOW()to return a consistent value across multiple runs or across rows in the same query. Some databases guarantee the same value for every row in a single statement, but running the query again later will always give a new result. - Using
NOW()to compare against sample data expecting a stable answer. Since sample datasets are static andNOW()is not, comparisons likeWHERE hire_date > NOW()will behave differently depending on when you run it and aren't a reliable way to test filtering logic. - Confusing
NOW()with a stored "created at" column.NOW()reflects the moment the query executes, not when a row was originally inserted into the table.
Related Functions
See also: CAST.