Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
wided
Posting Yak Master
218 Posts |
Posted - 2010-04-28 : 13:14:52
|
field in database datetimefield = var1data var1 = exemple : '12/04/2010 08:30:00'table = table1select datepart(hh, var1) from table1then result is inti want to have the result like this08 or 008 or 0008 .....i need this result thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-04-29 : 04:11:15
|
select right('00'+convert(varchar(2),datepart(hh, var1)),2) from table1gives '08'. No, you're never too old to Yak'n'Roll if you're too young to die. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-04-29 : 06:24:56
|
orselect convert(varchar(2),var1,108) from table1MadhivananFailing to plan is Planning to fail |
|
|
|
|
|