Converting fields in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a few fields that are imported from aonther program. They are "time"
fields, although in the Dabase they are txt fields. (due to the way the
other program exports the data)

is there a way to convert those fields to actual time values to do time
calculations?

i have fields like 'StartTime' 'EndTime' 'PrevEndTime'

they are in the format 'xx:xx:xx' where x is a number 0-9 and the clock is
a 24 hr clock, i.e. 1 P.M. is 15:00:00.

i want to convert those text (remember they are text fields) to time fields
co i can calculate "End time minus Start time" (for total time) and "Start
time minus prevendtime" for "time between sets"

is this possible, or would i have to try and change the way the program
exports the data, and make it into a time field?
 
Mike said:
I have a few fields that are imported from aonther program. They are "time"
fields, although in the Dabase they are txt fields. (due to the way the
other program exports the data)

is there a way to convert those fields to actual time values to do time
calculations?

i have fields like 'StartTime' 'EndTime' 'PrevEndTime'

they are in the format 'xx:xx:xx' where x is a number 0-9 and the clock is
a 24 hr clock, i.e. 1 P.M. is 15:00:00.

i want to convert those text (remember they are text fields) to time fields
co i can calculate "End time minus Start time" (for total time) and "Start
time minus prevendtime" for "time between sets"

is this possible, or would i have to try and change the way the program
exports the data, and make it into a time field?

TimeValue([YourField])
 
Is there a way to have a "Long Date" that ueses the 24 hr. clock w/o haveing
the A.M./P.M.??

I have the Total time = finishtime - starttime. this should be something
like 3:43:54 as in it took 3 hrs, 43 min and 54 sec to do the task. however
when i do my calculation (the total time field is set to long date) it comes
up as 3:43:54 A.M. as in 43 minutes and 54 seconds past the third hour of
the day.

i know i can just set to short date, but i would like to have the seconeds
in there (seconds matter) :-)

any help would be appreciated.
 
Mike said:
Is there a way to have a "Long Date" that ueses the 24 hr. clock w/o haveing
the A.M./P.M.??

You are not limited to the "named" formats. Use an explicit format string
like...

"mm/dd/yyyy hh:nn:ss"
 
Now, how would i check if statements in VBA? Like if the time spills over
such as the end time is say 1:30 am but the start time was 11 PM (of the
previous night) just doing a finish minus start would say that was 21.5
hours (time is absolut value, right?) between start an finish when in
actuallity there was 2.5 hours. right?

i wanted to check if the finish time was less than the start time. that way
the math could add a step where the time is subtracted from 24, thus giving
the correct time, right?

i just have

If [FinishTime]<[HeatStartTime]
TotalHeatTime = 24 - TotalHeatTime (it could also be
24-([heatstart]-[finish]) right?)
Endif

but it comes with Compile Error: Expected Then or GoTo

help?
 
Back
Top