For the ruby on rails application. i have to generate last one year
report.
so i think just do like this.
Take the current system data, then subtract one year, den select data
from
MySQL with this new date.
my question is how to subtract one year from current date in ruby,
basically the format of date in MySql is YYYY-MM-DD. so how to subtract
one
year from this.
i tried one…
*time = Time.new
*
*puts ddat = time.strftime("%d-%m-%Y") *
*
* here just i change dat format to DD-MM-YYYY, and then try to subtract
1.
But it shows error…
*
* how to solve this…? and have any problem in this logic…?
For the ruby on rails application. i have to generate last one year report.
my question is how to subtract one year from current date in ruby, basically
the format of date in MySql is YYYY-MM-DD. so how to subtract one year from
this.
i tried one…
time = Time.new
puts ddat = time.strftime(“%d-%m-%Y”)
get each month data between year. ie [ 2010-12-13 to 2011-12-13]. here i
got this current date and last date in rails. have any idea to select
that? i have to fetch the data in each month from database…?
SELECT count(id) from customers where created_at > “2010-12-13”
In the above query i need to change into a variable* last_year instead
of
“2010-12-13” *. and how to convert this MySQL query into rails query.
also give me a link to study the rails queries
Date.today.month or Time.now.month to get the month then how will
continue. i think about that on how to continue. But i can’t proceed. i
need to take the each month report from the one year.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.