Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert string to HH:MM

Status
Not open for further replies.
If it's always in that format, you could do it as
Code:
split({your.field},".")[1] & ":" 
& split({your.field},".")[2]
If the data varies it would be more complex, check ubound. Also the formula I gave would give you 38:2. You might need to edit a bit more, something like
Code:
ToText(@second_bit, "00")

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
A simpler method would be to convert it to a time, then format it.
Code:
ToText((Time({your.string)), "HH:mm"


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Sorry, that should be
Code:
ToText((Time({your.string)), "HH:mm")

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Try this variation on Madawc's solution:

if ubound(split({your.field},".")) > 0 then
(
split({your.field},".")[1] & ":"
& totext(val(split({your.field},".")[2]),"00")
) else
{your.field}

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top