Sunday, 27 September 2009

Get current date and time in SQL

There may be times where you will need to insert the current date and time into a database i.e. to record when a transaction has taken place. The command to display this timestamp is as follows :

select getdate() 'Current Date'

If you type this into query analyser you will get the current date and time in a column entitled 'Current Date'.

No comments:

Post a Comment