February 4, 2009 at 1:25 pm
I need to pass the number of seconds as an integer number from a datetime field to a RS report. i.e. value '2009-02-04 00:00:00.000' but I'm not sure what the sql syntax ix.
Any clues?
thx,
John
February 4, 2009 at 1:28 pm
Clarify please, number of secods from when?
February 4, 2009 at 1:31 pm
Have you looked at the DatePart function? Won't that do what you need?
- 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
February 4, 2009 at 1:32 pm
I apologize. Actually I need to pull the hh:mm:ss from the datetime field. The sample value is 2009-02-04 12:29:49.753
Hope this helps,
February 4, 2009 at 1:32 pm
[font="Verdana"]I'd suggest you start with the datepart function. Look it up in SQL Server Books Online (BOL).[/font]
February 4, 2009 at 1:46 pm
latingntlman (2/4/2009)
I apologize. Actually I need to pull the hh:mm:ss from the datetime field. The sample value is 2009-02-04 12:29:49.753Hope this helps,
Little more clarification, you need to pass this for above: 12:29:49.753?
February 4, 2009 at 2:03 pm
I need to display the time when the subscription ran. For example; a subscription ran at 20:59:58 on 02-03-2009, which would be the value in field RunDate '2009-02-03 20:59:58.687'.
Also, please notice that the sample time above means the job ran at 8:59:58 PM. My preference is not to show it in military time. Right now I'm using syntax CONVERT(varchar(10),TimeStart,108) and it works but it gives me military time (20:59:58). I'm almost there.
February 4, 2009 at 2:09 pm
Try this: select right(convert(varchar(40), getdate(), 109), 14)
February 4, 2009 at 2:12 pm
[font="Verdana"]Are you displaying this in a reporting services report? Because if so, you can return the actual datetime value, and then change the field format on the report so that it only display the time portion.
Otherwise, try something like this:
select substring(convert(varchar, getdate(), 109), 13, 14)
[/font]
February 4, 2009 at 2:23 pm
Lynn and Bruce, unfortunately that doesn't give me the desired results. I'll just take the easy route and format it in RS.
thx,
John
February 4, 2009 at 2:24 pm
Actually, that is the best idea yet.
February 5, 2009 at 6:46 am
Gotta agree with that one. If it's being formatted for human-readability, it's better to do that in the presentation layer, not in the database.
- 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
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply