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... -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 March 2010 09:00, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 March 2010 09:00, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 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> > 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... > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> On 12 March 2010 09:00, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> 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. > > Colinnow i m going to store the time 24 hour format... so is there any funtion to convert the 12hour time to 24 hours -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 March 2010 09:27, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> now i m going to store the time 24 hour format... > > so is there any funtion to convert the 12hour time to 24 hoursYou 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 received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 March 2010 09:27, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 12 March 2010 09:00, Newb Newb <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> 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 > > now i m going to store the time 24 hour format... > > so is there any funtion to convert the 12hour time to 24 hoursYou might be able to use DateTime.strptime to convert to DateTime which you can then convert to whatever format you want. See http://www.stephenchu.com/2007/11/parsing-time-in-custom-format-in-ruby.html for an example. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.