My model Enrollment has a time field called delivery_time. How do I set it to 8:00AM? In my migration, I had it do: t.time :delivery_time, :default => "8:00AM" But when I go into the console and output the value of delivery_time, it spits out "Sat Jan 01 08:00:00 +0000 2000" Why is it doing this? WHAT I''M TRYING TO DO: What I want to do is have a condition statement like this: ModelName.find(:all, :conditions => [":delivery_time = ?", Time.now.hour] --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
mel ram
2008-Jun-11 02:06 UTC
Re: How to save time and compare only the hour & minute part??
Here is some context: My app sends out an email every day to it''s users with some info. When the user signs up, they decide what time they want to recieve their daily email. The subscription is managed by a model called Enrollment, which has the fields last_deliver_date and delivery_time. I need to create Enrollment.due that return all enrollments that have a last_delivery_date older than 1 day and has a delivery_time that is within 1 hr of now On Jun 10, 6:44 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote:> My model Enrollment has a time field called delivery_time. How do I > set it to 8:00AM? > > In my migration, I had it do: > > t.time :delivery_time, :default => "8:00AM" > > But when I go into the console and output the value of delivery_time, > it spits out "Sat Jan 01 08:00:00 +0000 2000" > > Why is it doing this? > > WHAT I''M TRYING TO DO: > > What I want to do is have a condition statement like this: > > ModelName.find(:all, :conditions => [":delivery_time = ?", > Time.now.hour]--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Craig White
2008-Jun-11 02:24 UTC
Re: How to save time and compare only the hour & minute part??
On Tue, 2008-06-10 at 19:06 -0700, mel ram wrote:> Here is some context: > > My app sends out an email every day to it''s users with some info. When > the user signs up, they decide what time they want to recieve their > daily email. > > The subscription is managed by a model called Enrollment, which has > the fields last_deliver_date and delivery_time. > > I need to create Enrollment.due that return all enrollments that have > a last_delivery_date older than 1 day and has a delivery_time that is > within 1 hr of now > > On Jun 10, 6:44 pm, mel ram <mel...-IA9i2KS8NFBpEKysQ+xqfPpXobYPEAuW@public.gmane.org> wrote: > > My model Enrollment has a time field called delivery_time. How do I > > set it to 8:00AM? > > > > In my migration, I had it do: > > > > t.time :delivery_time, :default => "8:00AM" > > > > But when I go into the console and output the value of delivery_time, > > it spits out "Sat Jan 01 08:00:00 +0000 2000" > > > > Why is it doing this? > > > > WHAT I''M TRYING TO DO: > > > > What I want to do is have a condition statement like this: > > > > ModelName.find(:all, :conditions => [":delivery_time = ?", > > Time.now.hour]---- I''m still a bit vague on what you are trying to accomplish overall - i.e. is this a one time shot e-mail or will this recycle but anyway... I would probably have a date field for the sending date and a number field for the hour 0..23 and then I would find_all == hour and run this on an hourly basis (gathering what I can from above) Craig --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---