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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to get a regular time value from a military time 3

Status
Not open for further replies.

BobMcConnell

Programmer
Jan 8, 2004
6
US
the values are 1000
1400
1600
 
If your field is non numeric, create a formula like this to convert it to Time type:
Code:
Time (val(Left({table.field},2)), val(Right({table.field},2)), 0)
If it is numeric, you can adjust the formula like this:
Code:
Time (val(Left(ToText({table.field},0,""),2)), val(Right(ToText({table.field},0,""),2)), 0)

~Brian
 
I forgot to mention that once you have converted it to a Time type, you can format it in what ever Time format you want.

You can do this by placing the field on your report, Right clicking it, and choosing Format field.
Click the Time tab.
You can use one of the preset formats or click the customize button to create a custom format.

~Brian
 
Brian,

Thank you for your help - especially so quickly. When I paste in this formula (the field is a number) and replace table.field with the fieldname I get the message "The field name is not known". What am I doing wrong?
 
Try deleting each instance of "{table.field}" from the formula, and add the field from the Field list by double clicking it in the Field list in the Formula Editor. Make sure that the cursor is where you want to the field to end up before you double click.

If this doesn't solve the problem, please post your formula.

~Brian
 
BRIAN,

THANKS FOR THE HELP BUT WHEN I PLUG THE FIELD NAME WHICH IS A NUMBER INTO THE FORMULA I GET AN ERROR THAT SAYS THE FIELD DOES NOT EXIST. ANY IDEAS
 
SORRY,

DIDN'T SEE YOUR LAST MESSAGE - HERE IS THE FORMULA

Time (val(Left(ToText({{vSubjectAppointment.BeginTime}},0,""),2)), val(Right(ToText({{vSubjectAppointment.BeginTime}},0,""),2)), 0)
 
You have double curlicue brackets--try removing them as in:

Time (val(Left(ToText({vSubjectAppointment.BeginTime},0,""),2)), val(Right(ToText({vSubjectAppointment.BeginTime},0,""),2)), 0)

-LB
 
Just for kicks, here's another:
Code:
Time(int({vSubjectAppointment.BeginTime} / 100), {vSubjectAppointment.BeginTime} mod 100, 0)
-dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top