Parhaps one of these days we will see:
DTDiff(datetime,datetime) returns a string in the format
'Days,Hours,Minutes,Seconds'
i.e. DTDiff('10/1/2012 12:45:00 PM','10/2/2012 3:01:03 AM')
returns '0,2,16,3' regardless of the time settings.
Dennis McGrath
Software Developer
QMI Security Solutions
1661 Glenlake Ave
Itasca IL 60143
630-980-8461
[email protected]
From: [email protected] [mailto:[email protected]] On Behalf Of Bill Downall
Sent: Wednesday, October 17, 2012 6:39 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: Datetime tutorial
Yes, it's milliseconds if your time format includes ss.sss, it's centiseconds
if time format is ss.ss, deciseconds if time format contains ss.s, and seconds
if time format has ss.
If you subtract DATES from each other, the integer is always days.
You should always check or enforce the appropriate time format before doing
subtraction with time or date-time values. ADDSEC gives the same result no
matter what the format, so I would recommend you use that instead of just
adding integers to datetime or time, the way we had to in the very old days.
Adding integers to dates should always be a date, integer number of days away,
but ADDDAY is clear in its definition, so I would recommend that, too.
Bill
On Wed, Oct 17, 2012 at 2:55 AM, Alastair Burr
<[email protected]<mailto:[email protected]>> wrote:
What else can it mean, Bill? Does it return milliseconds if the time format
does? Or minutes if the seconds are not included?
I couldn't find anything in the help files because I could find a subject to
look under.
Regards,
Alastair.
From: Bill Downall<mailto:[email protected]>
Sent: Tuesday, October 16, 2012 7:52 PM
To: RBASE-L Mailing List<mailto:[email protected]>
Subject: [RBASE-L] - Re: Datetime tutorial
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]<mailto:[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]<mailto:[email protected]>
Sent: Tuesday, October 16, 2012 4:08 PM
To: RBASE-L Mailing List<mailto:[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