Want to get current datetime
to insert into lastModifiedTime
column. I am using MySQL
database. My questions are:
is there a function available in SQL? or
it is implementation depended so each database has its own function for this?
what is the function available in MySQL?
NOW() returns 2009-08-05 15:13:00
CURDATE() returns 2009-08-05
CURTIME() returns 15:13:00
I want my datetime, and I want it now()!
For MySQL, anyway.
Hope this helps...
Rob
I guess NOW() doesn't work sometime and gives error 'NOW' is not a recognized built-in function name.
Hope it helps!!! Thank You. https://docs.microsoft.com/en-us/sql/t-sql/functions/getdate-transact-sql
For SQL Server use GetDate() or current_timestamp. You can format the result with the Convert(dataType,value,format). Tag your question with the correct Database Server.
Complete answer:
1. Is there a function available in SQL?
Yes, the SQL 92 spec, Oct 97, pg. 171, section 6.16 specifies this functions:
2. It is implementation depended so each database has its own function for this?
Each database has its own implementations, but they have to implement the three function above if they comply with the SQL 92 specification (but depends on the version of the spec)
3. What is the function available in MySQL?
(As SixFootTallRabbit says)