Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Formatting Time Post Reply Post New Topic
Author Message
ctbny
Newbie
Newbie


Joined: 24 Aug 2007
Location: United States
Online Status: Offline
Posts: 4
Quote ctbny Replybullet Topic: Formatting Time
     Posted: 10 Jan 2008 at 2:21pm
I am trying to format a time value.  The original value is in minutes and I am converting it to HH:MM, so I used
 
CTime({Table.Mins} \ 60, {Table.Mins} mod 60, 0)
 
which works fine until I have a time over 24 hours, which causes an error.  So I'm trying to figure out why I can't express 40 hours as 40:00.  Apparently it's assuming I'm trying to represent a time of day, which I'm not.  I'm trying to represent a time duration.  Anyone know how to achieve this?
IP IP Logged
rahulwalawalkar
Senior Member
Senior Member
Avatar

Joined: 08 Jun 2007
Location: United Kingdom
Online Status: Offline
Posts: 731
Quote rahulwalawalkar Replybullet Posted: 11 Jan 2008 at 2:45am

Hi,

Can you post some sample data to playaround?

Cheers

Rahul

 

 

IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 11 Jan 2008 at 4:39am
CTime will attempt to express a time of day.  That's what it's for.

Try this.  It's a wacky solution I happened on.

DollarFR({Table.Mins}/60.00,60)

What this function does is, essentially, express a decimal as a fraction, but in decimal format.  Yeah, that doesn't really make sense.  Let's try some examples:

DollarFR(3.25,4) = 3.1      because .25 = 1/4
DollarFR(3.25,8) = 3.2      because .25 = 2/8
DollarFR(3.25,60) = 3.15   because .25 = 15/60

Then, when formatting your field, just change the decimal character to a colon, and you've got what you want.  (Though, keep in mind, I have no idea how math on DollarFR values works, so do all your math on the original Mins field.)


IP IP Logged
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