TimeSerial

K

KHogwood-Thompson

Hi,
I have a table that stores a numeric value in the [TIME WRITTEN] field. Most
of the values are 6 numerics long i.e. 12:25:36 would store as 122536 want to
convert the values in that field to the format 00:00:00
I have used the following formula to do this:

TimeSerial(Left([TIME WRITTEN],2),Mid([TIME WRITTEN],3,2),Mid([TIME
WRITTEN],5,2))

This works fine on most of the values, however there are some values that
are 5 characters in length with the preceding zero not stored, i.e 08:56:34
would store as 85634. When the formatting is run on these values I get Errors.

Can anyone help with an adjustment to the formula to cater for these values??
 
P

pietlinden

Hi,
I have a table that stores a numeric value in the [TIME WRITTEN] field. Most
of the values are 6 numerics long i.e. 12:25:36 would store as 122536 want to
convert the values in that field to the format 00:00:00
I have used the following formula to do this:

TimeSerial(Left([TIME WRITTEN],2),Mid([TIME WRITTEN],3,2),Mid([TIME
WRITTEN],5,2))

This works fine on most of the values, however there are some values that
are 5 characters in length with the preceding zero not stored, i.e 08:56:34
would store as 85634. When the formatting is run on these values I get Errors.

Can anyone help with an adjustment to the formula to cater for these values??

Test for the length of the string first.

iif(len([Time Written])=6, TimeSerial(Left([TIME WRITTEN],2),Mid([TIME
WRITTEN],3,2),Mid([TIME WRITTEN],5,2)), TimeSerial(Left([TIME
WRITTEN],1),Mid([TIME WRITTEN],3,2),Mid([TIME WRITTEN],5,2)))
 
K

KHogwood-Thompson

Much more straightforward, thanks Rick!
--
K Hogwood-Thompson


Rick Brandt said:
KHogwood-Thompson said:
Hi,
I have a table that stores a numeric value in the [TIME WRITTEN]
field. Most of the values are 6 numerics long i.e. 12:25:36 would
store as 122536 want to convert the values in that field to the
format 00:00:00
I have used the following formula to do this:

TimeSerial(Left([TIME WRITTEN],2),Mid([TIME WRITTEN],3,2),Mid([TIME
WRITTEN],5,2))

This works fine on most of the values, however there are some values
that
are 5 characters in length with the preceding zero not stored, i.e
08:56:34 would store as 85634. When the formatting is run on these
values I get Errors.

Can anyone help with an adjustment to the formula to cater for these
values??

Format(FieldName, "00:00:00")
 

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

Similar Threads

Query - Exclude Time 0
Complex Query 1
Input Mask - quick question 6
Cstr/CDate Query 3
Modify Time Field 1
Calculating with 2 different formats 3
Need query to calculate my SLA Begin Time 18
Lost in time! 5

Top