On 2 February 2012 15:18, amvis wrote:
I got it from this
:day_of_week =>u.bill_date.day,
:day_of_month =>
(Date.new(Time.now.year,12,31).to_date<<(12-u.bill_date.month)).day ,
:month_of_year =>u.bill_date.month,
:year => u.bill_date.year
Can i use this same way to get the day, month, year from the default field
created_at..? Yest
i mean :day_of_week =>u.created_at.day
i just tried that but got some error .day.. i think created_at field with
timestamp. so that will be the problem...?
If you get an error you have to look at it and work out what it means,
which is not always easy but you will get better at it with practice.
It is no good asking for help here and just saying you got some error,
you must provide the details, but first try and understand the error.
Also read up on and experiment with the rails console, it can be very
useful for trying things out, for example:
$ rails console
Loading development environment (Rails 3.1.3)
ruby-1.8.7-p302 > u=User.first
User Load (0.9ms) SELECT `users`.* FROM `users` LIMIT 1
=> #<User id: 1, <snip>, created_at: "2011-11-25 22:01:46",
updated_at: "2011-12-16 15:33:24", approved: true>
ruby-1.8.7-p302 > u.created_at.day
=> 25
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@googlegroups.com.
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.