how can we get the experience years between two dates(ex:2012-01-11 to
2009-02-01)?
I need only years and not in months and days and if less than year
should get 0 .
···
--
Posted via http://www.ruby-forum.com/.
how can we get the experience years between two dates(ex:2012-01-11 to
2009-02-01)?
I need only years and not in months and days and if less than year
should get 0 .
--
Posted via http://www.ruby-forum.com/.
Post some things you've tried.
--
Posted via http://www.ruby-forum.com/.
How might you modify that to handle years?
--
Posted via http://www.ruby-forum.com/.
I have a coded solution to this problem, and I will share it with you if
I feel like you've made an effort.
--
Posted via http://www.ruby-forum.com/.
Xavier why don't you try helping other instead of asking a multitude of
random questions?
--
Posted via http://www.ruby-forum.com/.
Matt Mongeau wrote in post #1098484:
Post some things you've tried.
I tried the below :
def calculate_difference
minutes = (Date.parse("2009-06-20") - Date.today).to_i / 60
days = minutes / (24*60)
minutes -= days * 24*60
hours = minutes / 60
minutes -= hours * 60
"#{days}d#{hours}h#{minutes}m"
end
which is not the one - I am looking for.
--
Posted via http://www.ruby-forum.com/\.
Matt Mongeau wrote in post #1098486:
How might you modify that to handle years?
I was actually trying to get the years from the below :
Yr = #{days}/ 365
but not working. And thus I am looking for another technique.
--
Posted via http://www.ruby-forum.com/\.
OK, now I'm just baffled...you are looking for years, so you post a
"thing you tried" which doesn't even reference years in the slightest.
Where did you get that code? Just a random post from somewhere or did
you write that gem yourself (no pun intended).
This is getting too obvious that you aren't here for "help" you're here
for programmers to work for you. You even went so far as to change your
name from "Love you Ruby" to this so people would help you again. It's
just pathetic.
-Ryan
On 2/22/13 1:43 PM, Xavier R. wrote:
Matt Mongeau wrote in post #1098484:
Post some things you've tried.
I tried the below :
def calculate_difference
minutes = (Date.parse("2009-06-20") - Date.today).to_i / 60
days = minutes / (24*60)
minutes -= days * 24*60
hours = minutes / 60
minutes -= hours * 60
"#{days}d#{hours}h#{minutes}m"
endwhich is not the one - I am looking for.
Use irb to find out what each expression actually returns.
Consider this:
(Date.parse("2009-06-20") - Date.parse("2009-06-18")).to_i
=> 2
Am 22.02.2013 20:43, schrieb Xavier R.:
Matt Mongeau wrote in post #1098484:
Post some things you've tried.
I tried the below :
def calculate_difference
minutes = (Date.parse("2009-06-20") - Date.today).to_i / 60
days = minutes / (24*60)
minutes -= days * 24*60
hours = minutes / 60
minutes -= hours * 60
"#{days}d#{hours}h#{minutes}m"
endwhich is not the one - I am looking for.
The technique is right; the details are wrong. Read the error message to
fix the syntax error, and look up floating point numbers if you need more
precision.
On Feb 23, 2013 6:59 AM, "Xavier R." <lists@ruby-forum.com> wrote:
Matt Mongeau wrote in post #1098486:
> How might you modify that to handle years?I was actually trying to get the years from the below :
Yr = #{days}/ 365
but not working. And thus I am looking for another technique.
Matthew Kerwin wrote in post #1098503:
Matt Mongeau wrote in post #1098486:
> How might you modify that to handle years?
Could you suggest any other technique please?
On Feb 23, 2013 6:59 AM, "Xavier R." <lists@ruby-forum.com> wrote:
The technique is right; the details are wrong. Read the error message to
fix the syntax error, and look up floating point numbers if you need
more
precision.
--
Posted via http://www.ruby-forum.com/\.
Matthew Kerwin wrote in post #1098503:
Matt Mongeau wrote in post #1098486:
> How might you modify that to handle years?
Any other technique could you suggest for the same?
On Feb 23, 2013 6:59 AM, "Xavier R." <lists@ruby-forum.com> wrote:
The technique is right; the details are wrong. Read the error message to
fix the syntax error, and look up floating point numbers if you need
more
precision.
--
Posted via http://www.ruby-forum.com/\.
Xavier R. wrote in post #1098506:
Could you suggest any other technique please?
Here's a strategy that might work:
* Read the error message.
* Lea el mensaje de error.
* エラーメッセージを読んでください。
* Прочитайте сообщение об ошибке.
* Basahin ang mga mensahe ng error.
* 阅读错误信息。
* Lue virheilmoitus.
دفعات بازدید: پیام خطا *
* Baca pesan kesalahan.
* Διαβάστε το μήνυμα σφάλματος.
(Apologies to native speakers if I got anything wrong in the above, no
offence intended.)
Additionally: read and comprehend our responses.
You said:
Yr = #{days}/ 365
but not working.
How "not working"?
Is there an error message? Can you read the message? Can you
copy-and-paste the error message into Google and see what you can
discover by yourself? Can you look up basic Ruby syntax and work out
what's wrong with the line you posted? If required, can you
copy-and-paste relevant messages or results into translate.google.com to
try and elucidate meaning therefrom?
Is it functioning, but producing a result other than what you expected?
Can you dig a bit deeper, using hints provided by some of us in earlier
posts to explore what your program is doing at every step? And maybe
work out the point at which it deviates from your expectation?
On this issue I will say no more.
--
Posted via http://www.ruby-forum.com/\.