Charles Baldo
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
(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.
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.
ASKER
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.
Not after change of soution by the way.
ASKER
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.
ASKER