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 |
klegrand
Starting Member
29 Posts |
Posted - 2006-03-28 : 08:15:25
|
Hi,I've the following issue. How can you format the time function to an integer ? I'm using the following code for this, --select datepart(m,getdate())--. If the time is 14:09:45 then it gives back '9'. I must have the '09'.With command can you use ?Thx |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-28 : 08:18:25
|
Where do you want to show the data?Use Front End application to format it to the way you wantMadhivananFailing to plan is Planning to fail |
|
|
ditch
Master Smack Fu Yak Hacker
1466 Posts |
Posted - 2006-03-28 : 08:18:59
|
select right('00' + ltrim(str(datepart(m,getdate()), 2)), 2)Duane. |
|
|
klegrand
Starting Member
29 Posts |
Posted - 2006-03-28 : 08:21:55
|
Thanks ditch,That's the answer for my problem... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-28 : 08:41:18
|
[code]select substring(convert(varchar(8), getdate(), 108), 4, 2), right(convert(varchar(5), getdate(), 108), 2)[/code] KHChoice is an illusion, created between those with power, and those without.Concordantly, while your first question may be the most pertinent, you may or may not realize it is also the most irrelevant |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2006-03-28 : 09:10:18
|
btw, an integer would just be 9, as 09 it would be a char.. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-28 : 09:14:56
|
quote: Originally posted by RickD btw, an integer would just be 9, as 09 it would be a char..
Thats what the scope of my first reply MadhivananFailing to plan is Planning to fail |
|
|
|
|
|
|
|