> Than Comparision in strings

zoup

New member
Local time
Today, 06:38
Joined
May 19, 2005
Messages
8
Hi. I am trying to compare 2 string values.

5:00
5:45
9:54
10:15

Lets say those are my values. Well in the formula >"5". 10 Will not show up correctly. Does anybody have a piece of code or something that will correctly display 10 as >"5". Any help greatly appreciated. Thanks
 
Because 1 < 5, to a string it is not 10 and 5, it is 1 and 5, so when comparing to 5 it only looks at the 1 part.
So you need to convert the string values to numeric to do what you want.
As an alternative, you can prefix the 5 with zero (05 < 10), but converting them to numerics would be better.
Of course since yours are time values, you need to convert them 24 hour time, or parse them before converting.
LEFT([TimeString],instr([TimeString],":")-1) should pull out the left protion, then you can use VAL or CINT or CLNG to convert to numeric. You can use that result to sort by, you don't have to display it in a query.
 
In an earlier thread, you said when you imported a text file, Access changed the time to something like 12:12:20 AM.

12:12:20 AM signifies a data/time field. Why not simply leave the field as a date/time field and set the criteria as > #5:0# in your query.

^
 
because..

because Im looking for hours and minutes.

My text file shows times it take to backup..

1:13 = 1 hour 13 minutes. Excel takes that and makes it 12 am and all this.

Im looking for hours and minutes.. So thats why Im forced to do it this way.

It was the only way I could think of conquering this problem.
 

Users who are viewing this thread

Back
Top Bottom