I thought this was simple, but my query yields a datetime value in 12 hour format and I can not get it to convert to 24hour (and I do need it in 24 hour).
The query below has three commented sections, and I denoted the steps, originally it is 24 hr, I convert it to float, average it convert it back and it's stuck in 12 hour.
I've tried several things to force it, including convert(datetime, Inserted,114)
I went through the help files list of conversions and tried all the styles that are labeled 24hr.
I am officially stumped.
query:
--select Inserted --24hr 2009-02-26 18:05:01.467
--select cast(Inserted as float)
--select avg(cast(Inserted as float))
select cast(avg(cast(Inserted as float)) as datetime) --12hr 2009-03-05 06:05:01.657
from Tablename
where
AND stagetime > getdate() - 14
AND stagetime < getdate()
The query below has three commented sections, and I denoted the steps, originally it is 24 hr, I convert it to float, average it convert it back and it's stuck in 12 hour.
I've tried several things to force it, including convert(datetime, Inserted,114)
I went through the help files list of conversions and tried all the styles that are labeled 24hr.
I am officially stumped.
query:
--select Inserted --24hr 2009-02-26 18:05:01.467
--select cast(Inserted as float)
--select avg(cast(Inserted as float))
select cast(avg(cast(Inserted as float)) as datetime) --12hr 2009-03-05 06:05:01.657
from Tablename
where
AND stagetime > getdate() - 14
AND stagetime < getdate()