Karen, Be careful with the definition of that integer you would get from subtracting one time from another. Sometimes it could mean seconds, but depending on your TIME format, it could mean something else, too.
Bill R>set var vthen = .#NOW R>sho v vthen 10/16/2012 2:49:03 PM R>set var vlapsed1 = (.#now - .vthen) R>sho v vlapsed% Variable = Value Type -------------------- ------------------------------ ------- vlapsed1 = 23 INTEGER R>sho time TIME format HH:MM:SS AP TIME sequence HHMMSS R>set time format 'HH:MM:SS.sss' R>set var vlapsed2 = (.#now - .vthen) R>sho v vlapsed% Variable = Value Type -------------------- ------------------------------ ------- vlapsed1 = 23 INTEGER vlapsed2 = 62208 INTEGER On Tue, Oct 16, 2012 at 2:42 PM, Alastair Burr <[email protected]>wrote: > Karen, > > You have had some answers about the SETting of the variable but you also > sneaked in a comment about subtracting one date/time from another. > > You’re right, as far as I know, you get an integer which is correct but > meaningless <g>. > > However, you can convert that number into a time using the ADDSEC function: > > SET VAR vNoNoneSenseTime = (ADDSEC(‘0:00:00’, .vYourResult) > > As long as it is less that 24 hours you’re fine. If not you have to work > out the days first! And, guess what? You can use the ADDDAY function almost > the same way! > > By the way, you can use a negative value for the second component to > subtract time or days. > > I am sure I must have said it here before but these are my most used and > most loved R:Base functions. If the time ones would go beyond the 24 hour > mark they’d be even better. (We all say things like “give it 48 hours”.) > > Regards, > Alastair. > > > *From:* [email protected] > *Sent:* Tuesday, October 16, 2012 4:08 PM > *To:* RBASE-L Mailing List <[email protected]> > *Subject:* [RBASE-L] - Datetime tutorial > > Here's one for the slow list... So far in my RBase career, I have > been blessedly spared from doing time arithmetic. That's about > to change. > > Although this client has purchased some version of 9.x, for the > immediate need this will be done in 7.6. > > I'm still trying to get an answer on whether I need to track time only, > or whether I will need a DateTime. I've been playing around with > DateTime and am totally confused. I've read all the help screens > I could find but mine aren't working that way! > > If I do: SET VAR vDatetime = .#NOW > the datatype is Text and cannot be used for arithmetic > > If I do: SET VAR vDatetime DATETIME = .#NOW > I get an error message about my variable not having the same data type > > If I do: SET VAR vDatetime DATETIME = (DATETIME(.#date, .#time)) > then I do get a datetime variable, and it appears I can use these for > arithmetic. If I subtract 2 datetime variables I get an integer which I > suspect is in seconds, right? So basically the .#now is not good for > calcs? > > Now part two. I set up a temp table with a column with DATETIME > data type, and am incapable of getting a value loaded. Using my now > valid DateTime variables, I try to do an insert and I get the same error > message above about invalid data types: > insert into testklt (onedatetime) values .vDateTime > > Hard to believe I've gotten away with not a single DateTime in my clients, > isn't it?? Well, now I might need to use it. > > > Karen >

