Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Report by time of day Post Reply Post New Topic
Author Message
JacobV
Newbie
Newbie


Joined: 09 Jan 2012
Online Status: Offline
Posts: 5
Quote JacobV Replybullet Topic: Report by time of day
    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!
IP IP Logged
acertik
Newbie
Newbie
Avatar

Joined: 16 Jan 2012
Online Status: Offline
Posts: 12
Quote acertik Replybullet 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



Edited by acertik - 25 Jan 2012 at 10:21pm
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 26 Jan 2012 at 1:01am
See my answer to your previous post;
 
 
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.


Edited by rkrowland - 26 Jan 2012 at 1:04am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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})
IP IP Logged
JacobV
Newbie
Newbie


Joined: 09 Jan 2012
Online Status: Offline
Posts: 5
Quote JacobV Replybullet 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.
IP IP Logged
JacobV
Newbie
Newbie


Joined: 09 Jan 2012
Online Status: Offline
Posts: 5
Quote JacobV Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.