Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Displaying a block time as hours and minutes Post Reply Post New Topic
Author Message
Taylor
Newbie
Newbie


Joined: 03 Dec 2009
Location: United States
Online Status: Offline
Posts: 5
Quote Taylor Replybullet Topic: Displaying a block time as hours and minutes
     Posted: 03 Dec 2009 at 4:10pm
Hey, I've been banging my head against this issue for a while, and I cannot use this new report without figuring this out...Any help would be appreciated.

My issue:

I am pulling data from a program called FOS, the database entry I need is the EFT (estimated flight time)...but the only three options Crystal Reports gives me are for these display styles: "07:23" "7:23PM" and "7.23".

I NEED to be able to turn one of those times into "7 hours and 23 minutes" format. I do not need seconds.

The report is not usable if I cannot figure this out, it is an absolute sticking point with my Department head.

If anyone can help me I would REALLY appreciate it!

For the record, and for anyone that can type up the code to do this (as I'm still learning!), the current code I use for my EFT to show as 07:23 style is:


WhilePrintingRecords ;
fos2time({QUOTE LEGS.EFT});




Edited by Taylor - 03 Dec 2009 at 4:17pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Dec 2009 at 7:03am
assuming the field is a time field and that it does not go over 24 hours use a formula field as:
totext({table.timefield},'H "hours" m "minutes"')
IP IP Logged
Taylor
Newbie
Newbie


Joined: 03 Dec 2009
Location: United States
Online Status: Offline
Posts: 5
Quote Taylor Replybullet Posted: 04 Dec 2009 at 8:43am
Great! But playing with that I keep getting this error:

"Bad number format string" Hmmm...does that refer to the data it's pulling out or something in the code?


The field is a time field, but of how long each leg will take, and not of what time it is.

Edited by Taylor - 04 Dec 2009 at 8:47am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 04 Dec 2009 at 8:49am
Data.
What is your raw data like?
What is the max Hours component?
IP IP Logged
Taylor
Newbie
Newbie


Joined: 03 Dec 2009
Location: United States
Online Status: Offline
Posts: 5
Quote Taylor Replybullet Posted: 07 Dec 2009 at 5:28pm
I was able to convince CTA to write the code for me, here's what it looks like:

WhilePrintingRecords;
//fos2time({QUOTE LEGS.EFT});


(
if {QUOTE LEGS.EFT}<60
then ""
else

if {QUOTE LEGS.EFT}<120
then totext(truncate({QUOTE LEGS.EFT}/60,0),0) + " hour "
else

totext(truncate({QUOTE LEGS.EFT}/60,0),0) + " hours "
)

+

(
if remainder({QUOTE LEGS.EFT},60)=0
then ""
else

if remainder({QUOTE LEGS.EFT},60)=1
then totext(remainder({QUOTE LEGS.EFT},60),0) + " minute"
else

totext(remainder({QUOTE LEGS.EFT},60),0) + " minutes"



thanks for all your effort!
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