SQL GETDATE() function returns the current date and time.
It returns the system date and time in the format ‘yyyy-mm-dd hh:mi:ss.mmm‘.
There are no parameters or arguments for the GETDATE() function.
Lets look at an example of GETDATE() in SQL.
SELECT GETDATE() AS CURRENTDATE
As you can see, It returns a current date and time of system in format ‘yyyy-mm-dd hh:mi:ss.mmm’
You can also get a date part from GETDATE() Function, like if you want to get a current day and month from GETDATE() function then you can use SQL Server DAY() and Month Function.
Lets look at an example to get a current day and month from GETDATE() function.
SELECT GETDATE() AS CURRENTDATE, DAY(GETDATE()) AS CURRENTDAY, MONTH(GETDATE()) AS CURRENTMONTH
As you can see, It returns current day and current monthn as a date part .
Remember, Here day() and month() function are SQL date function that is used to get a day and month from any date.
1,192 total views, 3 views today