Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Time string Post Reply Post New Topic
Author Message
Jonart
Newbie
Newbie


Joined: 02 Apr 2012
Online Status: Offline
Posts: 16
Quote Jonart Replybullet Topic: Time string
     Posted: 05 Mar 2013 at 8:25am
The database contains a "time" field which appears as 15:44:58 (hours, minues, seconds. The function IsTime tests as True. I need a formula that returns a string in this form:

3:45 pm

I have checked Help and written every syntax format I can think of using CStr and/or CTime. Most fail with "Too many arguments" message.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 05 Mar 2013 at 9:00am
you can just change the display of it by righ click in on it and select format field and then the Time tab. You can pick the "1:23 pm" option.
 
If you must convert to a string
totext({table.field},"h:mm tt")
IP IP Logged
Jonart
Newbie
Newbie


Joined: 02 Apr 2012
Online Status: Offline
Posts: 16
Quote Jonart Replybullet Posted: 05 Mar 2013 at 9:48am
I do need to convert to a string because it will be combined with other sytings in a single formul.

I keep getting "Too msny arguments", including using your syntax.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 06 Mar 2013 at 4:14am
your field is likely already a string type so you cannot use totext() on it
 
probably the easiest solution is to convert it to time then back to text
totext(time({table.field}),"h:mm tt")
IP IP Logged
Jonart
Newbie
Newbie


Joined: 02 Apr 2012
Online Status: Offline
Posts: 16
Quote Jonart Replybullet Posted: 06 Mar 2013 at 4:37pm
That works. Thanks.
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