Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Time format programming Post Reply Post New Topic
Author Message
rvwinkle
Newbie
Newbie


Joined: 24 Feb 2010
Location: Canada
Online Status: Offline
Posts: 4
Quote rvwinkle Replybullet Topic: Time format programming
    Posted: 24 Feb 2010 at 7:31am
my field prints the time as "1700" but I need it to read as "5:00 pm".  Can someone tell me how to format this field?
Thanks,
Kim M, Toronto, Canada
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 24 Feb 2010 at 7:36am
I do not know of a direct way of doing it.  I have always created a formula.  Basically something like this.  You did not tell us the data type for the time, I am assuming it is a number.  I am not adding the code to put in the ':'.
 
if time >= 12 then totext(time) + " pm"
else totext(time) + " am"
 
I hope this helps.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Feb 2010 at 7:38am
Is it an actual time field?
If so just right click on it and select Format Field, select the Date and Time tab then select '1:23 pm' as the style.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 24 Feb 2010 at 7:48am
Duh!  I was thinking it as a number field or a string.
IP IP Logged
rvwinkle
Newbie
Newbie


Joined: 24 Feb 2010
Location: Canada
Online Status: Offline
Posts: 4
Quote rvwinkle Replybullet Posted: 24 Feb 2010 at 7:50am

It looks like it's not an actual time field as that option is not there. It is a string. That's why I need the formula instead.

Thanks,
Kim M, Toronto, Canada
IP IP Logged
rvwinkle
Newbie
Newbie


Joined: 24 Feb 2010
Location: Canada
Online Status: Offline
Posts: 4
Quote rvwinkle Replybullet Posted: 24 Feb 2010 at 7:52am
Kevlray:  nope didn't work. must be because it's a string field.

Edited by rvwinkle - 24 Feb 2010 at 7:53am
Thanks,
Kim M, Toronto, Canada
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 24 Feb 2010 at 8:00am

Is there a leading zero in the time field for values < 1000?

IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 24 Feb 2010 at 8:01am

is it always a length of 4?

Convert it using a formula
time(left(timefield,2)+':'+right(timefield,2) +':00')
 
then convert the look as needed as I indicated before.
IP IP Logged
rvwinkle
Newbie
Newbie


Joined: 24 Feb 2010
Location: Canada
Online Status: Offline
Posts: 4
Quote rvwinkle Replybullet Posted: 24 Feb 2010 at 8:06am
Thank-you
Thank-you
Thank-you
 
That worked!  I am so glad I found this forum. You guys were great and thanks for responding so quickly.
 
Cheers!Clap
Thanks,
Kim M, Toronto, Canada
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.035 seconds.