Robin Presto
Robin Presto

Reputation: 23

SQL NOW() function not working properly

I'm trying to insert the date in a a query, using the NOW() statement.

However only the Y-m-d are being inserted correctly, while the hours, minutes and seconds are all appearing zeros ( 00:00:00 )

Any reason for that?

Upvotes: 2

Views: 9673

Answers (2)

phadaphunk
phadaphunk

Reputation: 13283

Try this :

SELECT CURRENT_TIMESTAMP
or
SELECT GETDATE()
or
Select {fn NOW()}

Note the accolades in the function.

Upvotes: 1

dcp
dcp

Reputation: 55434

Did you check the type of the column you are inserting into? Make sure it's datetime, not just date.

Refer to the docs for more info.

Upvotes: 4

Related Questions