Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: convert text to time Post Reply Post New Topic
Author Message
chunkyluver
Newbie
Newbie


Joined: 26 Mar 2012
Online Status: Offline
Posts: 2
Quote chunkyluver Replybullet Topic: convert text to time
     Posted: 26 Mar 2012 at 5:54am
I have a field that holds hours and minutes. so 1:30 which means 1 hour and 30 minutes. How do i convert this text to hours and minutes?
 
FYI i need to divide this into 30 minute increments so 1:30 / 30 = 3
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 26 Mar 2012 at 6:47am
I would think you would have to separate out the hours and minutes and convert them to numbers.  The solution below should work, but there may be a better solution.

numbervar hours:=tonumber(left({timetext},instr({timetext},":")-1));
hours*60+tonumber(right({timetext},2));

Of course the {timetext} field would replaced by your field.  This formula just returns the total number of minutes.  You can add code to do the division by three if that is all you want to do with the number.

I hope this helps.
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