The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Time difference of more than 24 hours.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cyberjuda

Germany
Posts

Posted - 01/20/2015 :  06:31:03 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 9.1.0 (64-bit)
Operating System: Windows 7

Hi,

I am trying to subtract dates with time and put them in another column as minutes (numeric). I am using the following command and it works fine until the difference is more than 24 hours. I realize this is because of the hour command only reading up till 24. Can someone suggest a workaround?

col(1)=minute(col(4)-col(4)[1])+60*hour(col(4)-col(4)[1]);




lkb0221

China
497 Posts

Posted - 01/20/2015 :  09:52:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
wcol(1)[1] = 0;
for (int row = 2; row <= wks.nrows; row++) {
wcol(1)[row] = wcol(1)[row-1] + minute(wcol(4)[row]-wcol(4)[row-1])+60*hour(wcol(4)[row]-wcol(4)[row-1]);
}
Go to Top of Page

cyberjuda

Germany
Posts

Posted - 01/21/2015 :  05:51:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, it works great. Is there some way to do it without a loop? This is part of a big script and I want to reduce the time.
Go to Top of Page

lkb0221

China
497 Posts

Posted - 01/21/2015 :  09:35:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
col(1) = (col(4)-col(4)[1]) / time(00:01:00);

Edited by - lkb0221 on 01/21/2015 09:52:10 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000