Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert date within my SQL Statement 1

Status
Not open for further replies.

chuckh70

Programmer
Feb 4, 2004
71
US
The date in the database is in Unix time format,
and I need to group by that field for the whole day. and
display the result in a readable date format.

I am not sure how to do this.

Code:
select create_time as 'Date Open',count(*) as 'tcktOpen' from HPD_HelpDesk where Assigned_To_Group_ = 'System Help Desk' and status < 4 and Create_time >= 1101859200 group by create_time
 
Getting just the date is fairly easy. The time is a pain in the *ss. Changes are in Red.
Code:
select [COLOR=red]dateadd(dd, (Create_Time/86400), '1/1/1970')[/color] as 'Date Open',
    count(*) as 'tcktOpen'
from HPD_HelpDesk 
where Assigned_To_Group_ = 'System Help Desk' 
    and status < 4 
    and [COLOR=red]dateadd(dd, (Create_Time/86400), '1/1/1970')[/color] >= [COLOR=red]'12/1/2004'[/color]
group by [COLOR=red]dateadd(dd, (Create_Time/86400), '1/1/1970')[/color]
Give that a shot. If Should do the trick for you.

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
Perfect Thanks.

That was just what I was looking for.. Also saved me all the trouble of doing it on the page itself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top