Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: converting time Post Reply Post New Topic
Author Message
jerryngc
Newbie
Newbie


Joined: 04 Feb 2009
Location: United States
Online Status: Offline
Posts: 3
Quote jerryngc Replybullet Topic: converting time
     Posted: 04 Feb 2009 at 3:51pm
Report requires field contents converted to a diffeent format or value.
(from a 24 hour clock to a standard 12 hour clock)
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 04 Feb 2009 at 9:10pm
Right-click on the time (or datetime) field after you place it on the report and select "Format Date and Time".  Select the format you need or click on the Custom button and create a custom format.
 
-Dell
IP IP Logged
jerryngc
Newbie
Newbie


Joined: 04 Feb 2009
Location: United States
Online Status: Offline
Posts: 3
Quote jerryngc Replybullet Posted: 05 Feb 2009 at 9:55am
The field I want to format.. although it contains time data, is not a Crystal Report time field.  The field contains time data in 24HR format,  I want to change the contents of each record to 12HR format...
 
How do you format any string data field on the fly to another format?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Feb 2009 at 10:29am
What is the exact format of the data?  Knowing that, I should be able to give you a formula for it.
 
-Dell
IP IP Logged
jerryngc
Newbie
Newbie


Joined: 04 Feb 2009
Location: United States
Online Status: Offline
Posts: 3
Quote jerryngc Replybullet Posted: 05 Feb 2009 at 11:07am
Hey thanks for responding..
 
in this case the data would be something like -->  152231
HHMMSS  should be converted to something like 032331  converted
to 12 HR time format.
 
I think I might be able to figure out a formula .. the question is where does the formula go..?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Feb 2009 at 12:15pm
Create a formula to convert it to a Time type:
 
if not IsNull({table.timefield}) then
Time(ToNumber(Left({table.timefield}, 2)), ToNumber(Mid({table.timefield}, 3, 2)), ToNumber(Right({table.timefield}, 2)))
 
Place the formula on your report and format the time as you need it.
 
-Dell
 
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