now am selecting one date from table, so from that date i have to retrieve the day of week, day of month,year… Some ways i have tried but didn’t get that, actually i had tried with current date.
time = Time.new
time.wday
time.month…
so how to pass one date,which is from table and find the above stuffs…?
date is not a class type. It could be Date. Do you mean that the
column type in the database is date or that it is a string containing
a date or what? What does it show for the column type in schema.rb?
What happens when you do bill_date.month as I suggested?
By the way please remember to include the relevant parts of the
previous messages in your reply otherwise it is difficult to follow
the thread (particularly for those who may find the thread later and
hope to learn from it). Also please insert your reply at appropriate
point in previous message rather than posting at the top of the new
mail. Thanks.
date is not a class type. It could be Date. Do you mean that the
column type in the database is date or that it is a string containing
a date or what? What does it show for the column type in schema.rb?
What happens when you do bill_date.month as I suggested?
By the way please remember to include the relevant parts of the
previous messages in your reply otherwise it is difficult to follow
the thread (particularly for those who may find the thread later and
hope to learn from it). Also please insert your reply at appropriate
point in previous message rather than posting at the top of the new
mail. Thanks.
Colin
Sorry i forgot that, i will follow that way in next time…
Are you sure that does not give you the day of the month, I would have
expected wday to give day of week, though since you still have not
told use what type bill_date is then we cannot be sure.
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: