Print Page | Close Window

Report by time of day

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=15450
Printed Date: 26 May 2024 at 1:28pm


Topic: Report by time of day
Posted By: JacobV
Subject: Report by time of day
Date Posted: 25 Jan 2012 at 1:47pm
Hey all - Crystal newbie here. Please have patience :)

I have a report I need to break down by time of day.

For example, looking at a months worth of data I want to determine the volume of data that came in at 7am, 8am, 9am, etc..

My challenge that I am currently stuck on is that the date/time data I have is AM/PM not military. The way I have it setup currently is using split:

split(ToText ({time.field}),':')[1]

With this, however, 7am is no different than 7pm.  I tried Crystal's help and found DTSToTime but this doesn't appear to be a valid function in 2008.

The format of the date information is: 9/19/2011  10:13:12AM

Any thoughts on how to sort this data based on time of day best?

Thanks again for your help - greatly appreciated!



Replies:
Posted By: acertik
Date Posted: 25 Jan 2012 at 10:18pm
Here's how I would do it. Group your report based on the following formula:

if totext({time.field}, "H") = "0" then "12am"
else if totext({time.field}, "H") = "1" then "1am"
else if totext({time.field}, "H") = "2" then "2am"

etc...

Repeat these lines until you reach:

else if totext({time.field}, "H") = "23" then "11pm"

This is assuming you're grouping your report by the hour, and nothing more detailed than that, correct?

If that's the case, then that should do it!

Alexander Certik



Posted By: rkrowland
Date Posted: 26 Jan 2012 at 1:01am
See my answer to your previous post;
 
http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=15321&KW=time - http://www.crystalreportsbook.com/Forum/forum_posts.asp?TID=15321&KW=time
 
Before I can give you a definitive answer we need to know what datatype your timefield is and also the exact format in which it is displayed.
 
Regards,
Ryan.


Posted By: DBlank
Date Posted: 26 Jan 2012 at 3:54am
IMO-likely you can just use the hour function to get the value you need
hour({table.datetimefield})


Posted By: JacobV
Date Posted: 26 Jan 2012 at 10:36am
"The format of the date information is: 9/19/2011  10:13:12AM"

Is that the type of information you were looking for rkrowland? I saw you original post as well that you linked to, however, with the format of my field being so different than you had mentioned I (as you stated originally) was not successful.

Again, my biggest challenge that I am identifying at this time is that the time data that I have is in a 12 hour format so I when begin splitting the data it is not distinguished between am and pm. I end up with 12 data points instead of 24 in the end.

Sorry if I doing a poor job explaining this and thanks for everyone's help.
member_profile.asp?PF=14352&FID=7 -


Posted By: JacobV
Date Posted: 26 Jan 2012 at 10:42am
Originally posted by DBlank

IMO-likely you can just use the hour function to get the value you need
hour({table.datetimefield})


Perfect! Works simply and gives me exactly what I need.  Thanks Smile



Print Page | Close Window