SQL GETDATE() Function
SQL GETDATE() function returns the current database system date and time in the format ‘YYYY-MM-DD hh:mm: ss. mmm’.
Syntax
The GETDATE() function syntax is:
SELECT GETDATE();
Example
In this example, we use the GetDate() function in SQL to get the current date and time.
Query
SELECT GetDate() AS 'CurrentDATETime';
Output
Get Only Time Part from GETDATE() Function Example
In this example, we will get only the time part from the GETDATE() function in SQL.
Query
SELECT CONVERT(VARCHAR(8), GETDATE(),108)'hh:mi:ss'
Output
How to Get Current Date and Time in SQL?
There are many built-in functions to get the current date and time in SQL. In this article, we will discuss how to get the current date and time in SQL with examples.
Contact Us