The NOW()
function returns the configured timezone’s current date and time.
Figure 1 shows a visual representation of the NOW()
function.
NOW()
The NOW()
function does not take in any parameters.
The NOW()
function returns the current date and time.
Its output type depends on the context where it is used. For instance:
-- 1
SELECT NOW();
-- returns string in the format of YYYY-MM-DD HH:MM:DD.
-- 2
SELECT NOW() + 2;
-- returns number in the format of YYYYMMDDHHMMSS.uuuu
When adding or subtracting a number after
NOW()
, like so:SELECT NOW() + n
, the output will haven
seconds added on to the time.
When multiplying or dividing after
NOW()
, like so:
SELECT NOW()/n
, the entire number will be multiplied or divided byn
.
-- output type as stringSELECT NOW();-- output type as number plus add two seconds to current date and timeSELECT NOW() + 2;