Skip to content
Advertisement

Is there an sql script to get the date and time a query was run?

I wondered if anyone can help. I need to get the date and time an sql query was run. I would like the output to be in the following format; YYYY-MM-DDThh:mm:ss Does anyone know what sql to write get this information please?

Thanks

Advertisement

Answer

You can select the current timestamp in the query. The standard SQL for that is:

select . . ., current_timestamp
from . . .

Most databases support this. However, there are also bespoke methods such as getdate(), now() and sysdate.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement