April 8, 2009 at 1:55 pm
Hi All,
For the following if I get one digit e.g. "2" , how do I get 2 digits "02":
select datepart(hh,getdate()) - 12
thanks,
April 8, 2009 at 2:20 pm
select right('0' + cast(datepart(hh,getdate()) - 12 as varchar(2)), 2)
Try that.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
April 8, 2009 at 2:36 pm
Thanks G-Squared that works.
April 8, 2009 at 3:07 pm
Have also a look to this thread:
http://www.sqlservercentral.com/Forums/Topic692679-338-1.aspx
Greets
Flo
April 8, 2009 at 10:30 pm
Format 121 solves all problems!:
Select Right(Convert(varchar(16), getdate(), 121),5)
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply