results from console and server are different. i am importing a date as a string "05/07/2008 10:00 AM" c.my_date = Time.parse(row[6]) shows up as "2008-05-07" , the time is dropped but when i test this in the controller it works c.my_date = Time.parse("05/07/2008 10:00 AM") shows up correctly as a full date i am assuming that this has something with the way the data is being saved while importing. i can also inject the date in the model on the console and do a save with the correct results. can anyone explain what is going on and how i can solve this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
there was no reply to this and further searching reveals frustration from others but not concrete pointers. i would like to reiterate that it is not a db issue because when the values are injected to the model it appears correctly. this is from script/console. i would greatly appreciate some help on this issue. i am not going to try and run a loop and attempt to convert the data in the hopes that is an issue with csv, but from other posting i am anticipating further problems. On Apr 4, 9:49 pm, rashantha <rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> results from console and server are different. > > i am importing a date as a string > > "05/07/2008 10:00 AM" > > c.my_date = Time.parse(row[6]) shows up as "2008-05-07" , the time is > dropped > > but when i test this in the controller it works > > c.my_date = Time.parse("05/07/2008 10:00 AM") shows up correctly as a > full date > > i am assuming that this has something with the way the data is being > saved while importing. > > i can also inject the date in the model on the console and do a save > with the correct results. > > can anyone explain what is going on and how i can solve this.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hello-- On Apr 5, 2008, at 1:54 PM, rashantha wrote:> > there was no reply to this and further searching reveals frustration > from others but not concrete pointers. > > i would like to reiterate that it is not a db issue because when the > values are injected to the model it appears correctly. > this is from script/console. > > i would greatly appreciate some help on this issue. > > i am not going to try and run a loop and attempt to convert the data > in the hopes that is an issue with csv, but from other posting i am > anticipating further problems. > > On Apr 4, 9:49 pm, rashantha <rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> results from console and server are different. >> >> i am importing a date as a string >> >> "05/07/2008 10:00 AM" >> >> c.my_date = Time.parse(row[6]) shows up as "2008-05-07" , the time is >> dropped >> >> but when i test this in the controller it works >> >> c.my_date = Time.parse("05/07/2008 10:00 AM") shows up correctly as a >> full date >> >> i am assuming that this has something with the way the data is being >> saved while importing. >> >> i can also inject the date in the model on the console and do a save >> with the correct results. >> >> can anyone explain what is going on and how i can solve this.Here are some steps you can take to solve this: In console, do: p Time.parse("05/07/2008 10:00 AM").class compare the results to: p Time.parse(row[6]).class If these are different, why are they different? How about: p Time.parse("05/07/2008 10:00 AM").to_s versus: p Time.parse(row[6]).to_s If there aren''t any clues there, then please give people on the list an idea what is in row[6] and what you observe in your controller. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ross i have tried comparing several issue in the console as well as in the controller. Time.parse("05/07/2008 10:00 AM").class is a value of TIME i am storing the information in DATE field. row[6] is coming from CSV import. row[6] is correctly a value of string ie: "05/07/2008 10:00 AM" i have tried .to_s i have also stored row[6] in a STRING variable and it saves the entire information. i can then read the information in the console from DB, use Time.parse and inject it back into the DATE variable and all works well. but i have yet to figure out why in the controller the time component is dropped and only the "05/07/2008" is saved in the format "2008-05-07" without the time.> > Here are some steps you can take to solve this: > > In console, do: > > p Time.parse("05/07/2008 10:00 AM").class > > compare the results to: > > p Time.parse(row[6]).class > > If these are different, why are they different? > > How about: > > p Time.parse("05/07/2008 10:00 AM").to_s > > versus: > > p Time.parse(row[6]).to_s > > If there aren''t any clues there, then please give people on the list > an idea what is in row[6] and what you observe in your controller.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
SOLVED. col needed to datetime thanks ross for making me look the 20th time at it. http://dizzy.co.uk/ruby_on_rails/cheatsheets/rails-migrations On Apr 5, 6:09 pm, rashantha <rashan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> ross i have tried comparing several issue in the console as well as in > the controller. > > Time.parse("05/07/2008 10:00 AM").class is a value of TIME > > i am storing the information in DATE field. > > row[6] is coming from CSV import. > row[6] is correctly a value of string ie: "05/07/2008 10:00 AM" > i have tried .to_s > > i have also stored row[6] in a STRING variable and it saves the entire > information. > > i can then read the information in the console from DB, use Time.parse > and inject it back into the DATE variable and all works well. > > but i have yet to figure out why in the controller the time component > is dropped and only the "05/07/2008" is saved in the format > "2008-05-07" without the time. > > > > > Here are some steps you can take to solve this: > > > In console, do: > > > p Time.parse("05/07/2008 10:00 AM").class > > > compare the results to: > > > p Time.parse(row[6]).class > > > If these are different, why are they different? > > > How about: > > > p Time.parse("05/07/2008 10:00 AM").to_s > > > versus: > > > p Time.parse(row[6]).to_s > > > If there aren''t any clues there, then please give people on the list > > an idea what is in row[6] and what you observe in your controller.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---