Converting Time Format using expression Microsoft Access

M

mp80237

Hello,

I am connected with view only access to a SQL database. I am running
my queries needed through access. The dates/times in the SQL database
are formated 12 hour time and the date is included in the field. I
just use the time (Example: 1/4/2006 12:06:00 PM). In what I need it
to do I created time fields and converted the date/time to military
time using the TimeValue function (Example: StartTime:
TimeValue([iStartDate])). What I want is my end value of all my time
fields put together in this format:

13:36-13:38MDT/20:36-20:38:43GMT/4:36-4:38HKG/06:36-06:38SYD

But my query that is putting the times together is putting the times
back to 12 hour clock:

1:36 PM-1:38PMMDT/8:36 PM-8:38PMGMT/4:36 AM-4:38AMHKG/6:36 AM-6:38AMSYD

Here is my original code:

Outage: [StartTime] & "-" & [EndTime] & "MDT/" & [StartGMT] & "-" &
[EndGMT] & "GMT/" & [StartHK] & "-" & [EndHK] & "HKG/" & [StartSyd] &
"-" & [EndSyd] & "SYD"

Here is my code I tried and the results were the same:

Outage: (TimeValue([StartTime])) & "-" & (TimeValue([EndTime])) &
"MDT/" & (TimeValue([StartGMT])) & "-" & (TimeValue([EndGMT])) & "GMT/"
& (TimeValue([StartHK])) & "-" & (TimeValue([EndHK])) & "HKG/" &
(TimeValue([StartSyd])) & "-" & (TimeValue([EndSyd])) & "SYD"

Any ideas to get it to the military time without the AM/PM? Thanks for
the help!
 
M

mp80237

That worked! Thank you so much for the help!


This is a duplicate thread.
But anyway: use the format function, eg: format([EndTime],"hh:mm")

mp80237 said:
Hello,

I am connected with view only access to a SQL database. I am running
my queries needed through access. The dates/times in the SQL database
are formated 12 hour time and the date is included in the field. I
just use the time (Example: 1/4/2006 12:06:00 PM). In what I need it
to do I created time fields and converted the date/time to military
time using the TimeValue function (Example: StartTime:
TimeValue([iStartDate])). What I want is my end value of all my time
fields put together in this format:

13:36-13:38MDT/20:36-20:38:43GMT/4:36-4:38HKG/06:36-06:38SYD

But my query that is putting the times together is putting the times
back to 12 hour clock:

1:36 PM-1:38PMMDT/8:36 PM-8:38PMGMT/4:36 AM-4:38AMHKG/6:36 AM-6:38AMSYD

Here is my original code:

Outage: [StartTime] & "-" & [EndTime] & "MDT/" & [StartGMT] & "-" &
[EndGMT] & "GMT/" & [StartHK] & "-" & [EndHK] & "HKG/" & [StartSyd] &
"-" & [EndSyd] & "SYD"

Here is my code I tried and the results were the same:

Outage: (TimeValue([StartTime])) & "-" & (TimeValue([EndTime])) &
"MDT/" & (TimeValue([StartGMT])) & "-" & (TimeValue([EndGMT])) & "GMT/"
& (TimeValue([StartHK])) & "-" & (TimeValue([EndHK])) & "HKG/" &
(TimeValue([StartSyd])) & "-" & (TimeValue([EndSyd])) & "SYD"

Any ideas to get it to the military time without the AM/PM? Thanks for
the help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top