SQL Server- Get date and time from current system datetime with example

How to find out current date and time in sql server? Using GETDATE() function it is possible to retrieve system datetime. GETDATE() is system in sql server

Syntax :

SELECT GETDATE()

Examples:

SELECT GETDATE() as CurrentDate

Example with sql server 2000 and 2005, you can use below gatedate() function to get hours and minutes from system date.

SELECT convert(varchar(10), GETDATE(), 108) As hh:mi:ss

Here

hh –> Hours
mi –> Minutes
ss –> Seconds

Example of GETDATE() function in sql server 2008

SELECT convert(time,getdate()) as Hour/Minute/Seconds
SELECT convert(date,getdate()) as CurrentDate

 

Leave a Reply

  

  

  


8 − 4 =