Difference between 2 dates

S

Srinivasa Rao

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:
(e-mail address removed)
 
R

Robert Klemme

2008/9/15 Srinivasa Rao said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top