[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Difference between 2 dates

Srinivasa Rao

9/15/2008 12:11:00 PM

Hi all,

duration_val= Time.now.strftime("%Y-%m-%d %H:%M:%S")-start_time_Val

Start_time_val formate is also same formate ("%Y-%m-%d %H:%M:%S").


I could not able to subtract 2 datetimes . Please suggest me .

I am getting error like this
undefined method `-' for "2008-09-15 17:46:54":String



My mail id:
srinivasa_rao3@mindtree.com
--
Posted via http://www.ruby-....

1 Answer

Robert Klemme

9/15/2008 12:24:00 PM

0

2008/9/15 Srinivasa Rao <srinivasa_rao3@mindtree.com>:
> Hi all,
>
> duration_val= Time.now.strftime("%Y-%m-%d %H:%M:%S")-start_time_Val
>
> Start_time_val formate is also same formate ("%Y-%m-%d %H:%M:%S").
>
>
> I could not able to subtract 2 datetimes . Please suggest me .
>
> I am getting error like this
> undefined method `-' for "2008-09-15 17:46:54":String

As the error indicates: you need to subtract Time values and not String values.

Cheers

robert

--
use.inject do |as, often| as.you_can - without end