D
D. Stacy
The goal of this effort is to convert text data into time data. The data
comes in 0045, 0200, 0530, etc. BUT it does not always come in in 4 digit
text length strings.
The below expression works fine when the data is length = 4 but it produces
errors when it starts with a zero length string (fields that look blank but
in fact are one space).
CDate(IIf(IsError(FormatDateTime(IIf(Len([Cut_Time])=0,"",Left([Cut_Time],2)+":"+Right([Cut_Time],2)),0)),"",FormatDateTime(IIf(Len([Cut_Time])=0,"",Left([Cut_Time],2)+":"+Right([Cut_Time],2)),0)))
Review: Input 0050 or 1400 or 545 or " "
Ouput 12:50 AM or 2:00 PM or 5:45 PM or 12:00 AM
comes in 0045, 0200, 0530, etc. BUT it does not always come in in 4 digit
text length strings.
The below expression works fine when the data is length = 4 but it produces
errors when it starts with a zero length string (fields that look blank but
in fact are one space).
CDate(IIf(IsError(FormatDateTime(IIf(Len([Cut_Time])=0,"",Left([Cut_Time],2)+":"+Right([Cut_Time],2)),0)),"",FormatDateTime(IIf(Len([Cut_Time])=0,"",Left([Cut_Time],2)+":"+Right([Cut_Time],2)),0)))
Review: Input 0050 or 1400 or 545 or " "
Ouput 12:50 AM or 2:00 PM or 5:45 PM or 12:00 AM