PDOX 5.0 WIN - Lame question about using math with dates
Author Message
PDOX 5.0 WIN - Lame question about using math with dates
I am a novice user of Paradox. I am using version 5.0 for windows.
I need to create queries and reports that show length of time
in days. I have a starting date field and a closing date field.
I want to do the equivalent of subtracting the starting date
from the closing date to get the number of total days of service.
In older languages functions like DATEDIFF() would be used.
What is the best way to accomplish this in PDOX 5.0 for Windows?

Wed, 08 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates

I am a novice user of Paradox. I am using version 5.0 for windows.
//I need to create queries and reports that show length of time
//in days. I have a starting date field and a closing date field.
//I want to do the equivalent of subtracting the starting date
//from the closing date to get the number of total days of service.
//In older languages functions like DATEDIFF() would be used.
//What is the best way to accomplish this in PDOX 5.0 for Windows?

Simple.  Just subtract the first date from the last date and you get
the difference in days

Cheers!
Tim Gunther --
Visa USA

Thu, 09 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates
Quote:

>I am a novice user of Paradox. I am using version 5.0 for windows.
>//I need to create queries and reports that show length of time
>//in days. I have a starting date field and a closing date field.
>//I want to do the equivalent of subtracting the starting date
>//from the closing date to get the number of total days of service.
>//In older languages functions like DATEDIFF() would be used.
>//What is the best way to accomplish this in PDOX 5.0 for Windows?

>Simple.  Just subtract the first date from the last date and you get
>the difference in days

Well, that's what one would think, but a date minus a date returns a date,
in Paradox for Windows.

Yes, I know, "today minus yesterday" intuitively should be 1, but PdoxWin
tells you it's January 1, A.D. 1 (or some such date).

You'll need to explicitly cast it to a number value, and casting is only
allowed with ObjectPAL (you can't do it in a query):
x = longint(date1 - date2)

Jim

Fri, 10 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates

Quote:

>Well, that's what one would think, but a date minus a date returns a date,
>in Paradox for Windows.
>Yes, I know, "today minus yesterday" intuitively should be 1, but PdoxWin
>tells you it's January 1, A.D. 1 (or some such date).
>You'll need to explicitly cast it to a number value, and casting is only
>allowed with ObjectPAL (you can't do it in a query):
>   x = longint(date1 - date2)
>Jim

Hmm, I constructed a query on a table with a date field, then inserted the
following string into the field's criteria space:
_date,calc today-_date
ran the query, and lo and behold, I had an answer table with _numbers_ not
dates! I checked the date field's checkbox just to be sure, and reran the
query - sure enough, Answer.db's last  record's first field was 1/20/96 and
the second field was 2.00. So this method does seem to work.
Timotheus needs to be educated about using example elements in queries.

Sat, 11 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates
Quote:

>>Well, that's what one would think, but a date minus a date returns a date,
>>in Paradox for Windows.

>>Yes, I know, "today minus yesterday" intuitively should be 1, but PdoxWin
>>tells you it's January 1, A.D. 1 (or some such date).

>>You'll need to explicitly cast it to a number value, and casting is only
>>allowed with ObjectPAL (you can't do it in a query):
>>   x = longint(date1 - date2)

>>Jim
>Hmm, I constructed a query on a table with a date field, then inserted the
>following string into the field's criteria space:
>_date,calc today-_date
>ran the query, and lo and behold, I had an answer table with _numbers_ not
>dates! I checked the date field's checkbox just to be sure, and reran the
>query - sure enough, Answer.db's last  record's first field was 1/20/96 and
>the second field was 2.00. So this method does seem to work.
>Timotheus needs to be educated about using example elements in queries.

Oh.  I apologize for the misinformation; the problem I was explaining
only applies to ObjectPAL.  The following will not compile:
var
d1, d2, d3 date
n number
endvar
d1 = date()
d2 = date()+5
n = d2 - d1 <--- error: Incompatible types
d3 = d2 - d1 ; compiles OK
d3.view() ; shows January 5, 0001

Once again, my apologies.
Jim

Sat, 11 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates
The best way is: Number of Days = Number(NewDate - OldDate)

Sat, 11 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates

Quote:
>Oh.  I apologize for the misinformation; the problem I was explaining
>only applies to ObjectPAL.  The following will not compile:
>var
>   d1, d2, d3 date
>   n number
>endvar
>   d1 = date()
>   d2 = date()+5
>   n = d2 - d1 <--- error: Incompatible types

Right!

Quote:
>   d3 = d2 - d1 ; compiles OK
>   d3.view() ; shows January 5, 0001
>Once again, my apologies.
>Jim

OK - just don't let it happen again ;-)

Sun, 12 Jul 1998 03:00:00 GMT
PDOX 5.0 WIN - Lame question about using math with dates

Quote:
> I want to do the equivalent of subtracting the starting date
> from the closing date to get the number of total days of service.

Make sure that the variable to which you assign the number of days when
you do the subtraction is defined as a number.

Thu, 16 Jul 1998 03:00:00 GMT

 Page 1 of 1 [ 8 post ]

Relevant Pages

Powered by phpBB® Forum Software