Link to home
Start Free TrialLog in
Avatar of Charles Baldo
Charles BaldoFlag for United States of America

asked on

Need time in SQL

Please I need the current time

HH:MM  i do not want AM or PM the hours will always be 8 to 5  so I know 8 is always 8 am 1 always 1 pm

I need leading zero if below 10
ASKER CERTIFIED SOLUTION
Avatar of Nitin Sontakke
Nitin Sontakke
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Charles Baldo

ASKER

It worked, good enough thanks
It worked thank you
SELECT convert(varchar(5), getdate() ,108)

(nb: the length of 5 removes the seconds)

refer:
https://www.experts-exchange.com/articles/12315/SQL-Server-Date-Styles-formats-using-CONVERT.html
@PortletPaul

To my knowledge, this doesn't cater to adding '0' when hour is single digit.

For that reason, I had to resort to such convoluted solution.
Thanks both,  I had closed it Nitin solution worked, it was an ad hoc problem and solution that I needed fast.
It does add leading zero.  Try it.

Not after change of soution by the way.
Thank you PortletPaul   your solution is good, I went back and played with it again.  Thank you Nitin, your fast answer was appreciated and needed it worked and solved the issue.