| Author |
Message |
STATS1
Newbie
Joined: 24 Oct 2011
Online Status: Offline
Posts: 4
|

Topic: converting a string to a time field Posted: 11 Jun 2012 at 11:24am |
Hi there,
I am trying to convert a time field that is showing up as a string such as (955, 1955, or 131955) and wanting to convert it to a millitary time field such as (00:09:55, 00:19:55, 13:19:55).
Is there one formula in crystal that will handle all scenarios and easily convert them to the millitary time?
Thanks so much!
|
IP Logged |
|
|
|
CircleD
Senior Member
Joined: 11 Mar 2011
Location: United States
Online Status: Offline
Posts: 251
|

Posted: 11 Jun 2012 at 6:17pm |
|
No guarantees as I'm not real good with formulas but CStr(#3:20:30 PM#,"HH:mm:ss") should work.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 12 Jun 2012 at 3:44am |
If you don't want to convert it to a time field this might work...
picture(right("000000" + {table.field},6),"xx:xx:xx") Edited by DBlank - 12 Jun 2012 at 3:45am
|
IP Logged |
|
STATS1
Newbie
Joined: 24 Oct 2011
Online Status: Offline
Posts: 4
|

Posted: 13 Jun 2012 at 5:07am |
|
Hmmm..no luck with trying the last two ideas, but thanks for trying. As an update, the field isn't a string, it is actually coming accross as a number, but I just want to add the two ':' ':' in it. Any other thoughts for a formula which will do this?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 13 Jun 2012 at 5:13am |
|
picture(totext({table.numericfield},"000000"),"xx:xx:xx")
|
IP Logged |
|
STATS1
Newbie
Joined: 24 Oct 2011
Online Status: Offline
Posts: 4
|

Posted: 13 Jun 2012 at 5:33am |
Further to my last post, I tried entering for a formula: Time({field})
It comes out the way it should: 00:00:00 but I am only getting zeros, I am not actually getting the correct time...
Any other thoughts?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 13 Jun 2012 at 5:46am |
did you try
picture(totext({table.numericfield},"000000"),"xx:xx:xx")
?
|
IP Logged |
|
rkrowland
Senior Member
Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
|

Posted: 13 Jun 2012 at 5:48am |
As it's a number (ie no preceeding 0s for single digits) how do you determine which number relates to which unit of time?
youe example above, 955, the 9 is a single digit, doesn't that mean if the seconds was a single digit there'd be no leading 0?
eg a value of 135, without leading 0s the value could equate to either of the following;
00:13:05
or
00:01:35
Thanks,
Ryan.
|
IP Logged |
|
STATS1
Newbie
Joined: 24 Oct 2011
Online Status: Offline
Posts: 4
|

Posted: 15 Jun 2012 at 5:27am |

Yay!!
picture(totext({PIPDPM.PMADM#},"000000"),"xx:xx:xx")
This worked!!!!
Thanks so much!!
|
IP Logged |
|
|
|