Categories
Linux SQL Time Windows Windows 2000

SQL SERVER – Get Time in Hour:Minute Format from a Datetime – Get Date Part Only from Datetime

Get Current Date & Time

select GetDate()

SQL Server 2000/2005

SELECT
CONVERT(VARCHAR(8),GETDATE(),108) AS HourMinuteSecond,
CONVERT(VARCHAR(8),GETDATE(),101) AS DateOnly
GO

SQL Server 2008

SELECT
CONVERT(TIME,GETDATE()) AS HourMinuteSecond,
CONVERT(DATE,GETDATE(),101) AS DateOnly
GO

Leave a Reply

Your email address will not be published.