Get current date: getdate

The getdate function produces the current date and time in Adaptive Server internal format for datetime values. getdate takes the NULL argument, ().

To find the current system date and time, type:

select getdate() 
-------------------------- 
Aug 19 1997 12:45PM 
 
(1 row affected) 

You might use getdate in designing a report so that the current date and time are printed every time the report is produced. getdate is also useful for functions such as logging the time a transaction occurred on an account.

To display the date using milliseconds, use the convert function. For example:

select convert(char(26), getdate(), 109)
--------------------------
Aug 19 1997 12:45:59:650PM 
 
(1 row affected)

See “Changing the display format for dates” for more information.