sql server 2000 convert datetime to get hhmm

25,997

Solution 1

SELECT REPLACE(CONVERT(varchar(5), GETDATE(), 108), ':', '')

Solution 2

SELECT REPLACE(CONVERT(CHAR(5),GETDATE(),108), ':', '')

If you don't need colon, just remove it...

Share:
25,997
MAW74656
Author by

MAW74656

Updated on September 17, 2020

Comments

  • MAW74656
    MAW74656 almost 4 years

    I'm using

    convert(varchar(20), getdate(), 112)
    

    to convert getdate() to yyyymmdd format (ISO format), which works great. Now I need to do something similiar to get the time in hhmm format. How can I achieve this?

    Example: 12:10 pm should look like 1210, 3:43 pm should look like 1543.