Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Convert String to Time Post Reply Post New Topic
Author Message
CVIS Analyst
Newbie
Newbie
Avatar

Joined: 29 Oct 2007
Online Status: Offline
Posts: 2
Quote CVIS Analyst Replybullet Topic: Convert String to Time
    Posted: 28 Nov 2007 at 1:27pm
I am looking for a way to convert  a string which appears as a time 103030 (this is actually 10:30:30) to a time value so that calculations can be preformed on the field. I am using Crystal Reports XI. Thanks for your help.
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Nov 2007 at 1:53pm
You can use the picture function to map it to the proper date format and then use the CTime() function to convert it to a time data type.
CTime(Picture({field}, "xx:xx:xx"))

Then use the DateAdd() function to do calculations on the field.

I have all the Crystal Reports functions documented with sample code in Chapter 6 of my Crystal Reports Encyclopedia book


Edited by BrianBischof - 28 Nov 2007 at 1:56pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
CVIS Analyst
Newbie
Newbie
Avatar

Joined: 29 Oct 2007
Online Status: Offline
Posts: 2
Quote CVIS Analyst Replybullet Posted: 28 Nov 2007 at 2:04pm
Thank you for your help. When I use the CDate formula as you have suggested the field on the report is blank. Any suggestions?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 28 Nov 2007 at 2:26pm
That should be CTime() instead of CDate(). I originally wrote CDate() in my post but then changed it to CTime() once I read your question a second time. That should get you up and running.


Edited by BrianBischof - 28 Nov 2007 at 2:29pm
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
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.016 seconds.