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

Military conversion

Status
Not open for further replies.

trustsun

Technical User
Feb 4, 2004
73
US

I need to split this value into two separate fields; 6:00PM [AB-CF], it’s now in one field.

The time value needs to be converted into a military value. Any help, please. So, they need to look like this separate by fields.

1. [AB-CF]
2. 6:00PM but this needs to be in military time.
 
A starting point (SQL code):
SELECT Mid(yourField,InStr(yourField," ")+1) AS Field1, TimeValue(Left(yourField,InStr(yourField," ")-1)) AS Field2
FROM yourTable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I'm still getting both values in the first field and a error in the second one.

 
PH's solution worked exactly as he suggested. If you have a problem, you should post back with your query SQL view and the error message you are getting.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
PH has assumed that there is a space after the time and he has split the data into what comes after that space and what comes before. This is based on the data you provided.

If you have one or more spaces BEFORE the time the logic above will fail. You would need to remove those spaces with a TRIM function.
 
OK cheerio there are spaces, this is how the field look: (6:00 PM [AB-CF]), without the ().I need to spilt them into separate fields and converting the time value into military time.

thanks,
 
And this ?
SELECT Mid(yourField,InStr[!]Rev[/!](yourField," ")+1) AS Field1, TimeValue(Left(yourField,InStr[!]Rev[/!](yourField," ")-1)) AS Field2
FROM yourTable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top