concatenation problem

R

Rich

The following data is output from our production control program :
Log-in times on the floor are split between 2 fields; [Beg Hour]
and [Beg Min] (both number formatted). The problem is, if someone logs
in @ 14:02, the [Beg Min] field records just a "2", so when I
concatenate the two fields, I get 14:2. Being a number field, [Beg
Min] won't recognize a leading zero when I try to add one, and
obviously, this is only an issue when [Beg Min] <=9.
What is the easiest way to achieve my goal of ending up with one
field, that in the above circumstance would read 14:02, AND be in the
proper Date/Time format for comparison with other date/time fields?
Thanks in advance to all who reply.
Rich
 
J

John Spencer

Which will be a text value. If you need to compare this to values in a
datetime field, you will probably need to wrap the expression in the
timevalue function.


OR use CDate on the string

Or use this expression

CDate((60*[Beg hour] + [Beg Min])/1440)



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
K

Klatuu

Thanks, John, I forgot about the last bit
--
Dave Hargis, Microsoft Access MVP


John Spencer said:
Which will be a text value. If you need to compare this to values in a
datetime field, you will probably need to wrap the expression in the
timevalue function.


OR use CDate on the string

Or use this expression

CDate((60*[Beg hour] + [Beg Min])/1440)



'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

Format([Beg Hour], "00\:") & Format([Beg Min], "00")
 
J

John W. Vinson/MVP

What is the easiest way to achieve my goal of ending up with one
field, that in the above circumstance would read 14:02, AND be in the
proper Date/Time format for comparison with other date/time fields?

TimeSerial([Beg Hour], [Beg Min], 0)

will do it in one shot...
 
J

John Spencer

Dang! I forgot all about TimeSerial.


'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================

What is the easiest way to achieve my goal of ending up with one
field, that in the above circumstance would read 14:02, AND be in the
proper Date/Time format for comparison with other date/time fields?

TimeSerial([Beg Hour], [Beg Min], 0)

will do it in one shot...
 
R

Rich

   What is the easiest way to achieve my goal of ending up with one
field, that in the above circumstance would read 14:02, AND be in the
proper Date/Time format for comparison with other date/time fields?

TimeSerial([Beg Hour], [Beg Min], 0)

will do it in one shot...

Thanks to all who responded. As usual, the answers you all provided
were outstanding.
Rich
 

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