TIME - STR_TO_DATE

i have a time field in my table. it is of varchar data type.

i want compare the time between given times.

my stored time format is 09:25:01 am.

is there any way to compare my time field ?

i don t have any idea about mysql STR_TO_DATE function.. will it be usefull for my above problem..

please help me up to try it out...

i have a time field in my table. it is of varchar data type. i want compare the time between given times. my stored time format is 09:25:01 am. is there any way to compare my time field ?

You asked this two days ago...

i don t have any idea about mysql STR_TO_DATE function.. will it be usefull for my above problem..

Probably - if your DB is MySQL. The function turns a string into a date and you have a string that you need turned into a date.

please help me up to try it out...

Have you tried it? What happens? If you've got some way with it, and have a code example that doesn't quite work, then maybe we can work from there.

i have a time field in my table. it is of varchar data type.

i want compare the time between given times.

As was previously suggested you should at least consider changing the data type of the field in the db. I did not see any comment from you on this suggestion in the previous thread.

Colin

Colin Law wrote:

You haven't got a "Time" you've got a "STRING"... anything you do to it, you're going to have to do some work - and if your choice is to change a 12hr clock string into a 24hr clock string, I don't see that makes any difference to your problem, which was about how to search based on time...

Either:

a) Look at the SQL commands for the DB you're using which manipulate strings and dates. b) Change how you store the data into something that can be compared easily and reliably (so either a DB time/datetime field, or an integer of "minutes from midnight") - anything but a string.

You might be able to use DateTime.strptime to convert to DateTime which you can then convert to whatever format you want. See

for an example.

Colin