Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date problems in Dbase III+

Status
Not open for further replies.

nicksteel

Technical User
Jan 2, 2001
18
US
I use DB3 to check calculations in software I am developing that uses DBF files. I have it installed on Windows7 Pro 32bit with XP SP2 compatibility. The problem is comparing a date to CTOD(' / / ').

= or <> give the same results.

If I substitute [highlight #FCE94F]> CTOD('01/01/01')[/highlight] for [highlight #FCE94F]> CTOD(' / / '}[/highlight], I get different results. All my dates are empty or during 2013. I have tried SET CENTURY ON.

 
can you post your code?



Ali Koumaiha
TeknoSoft Inc.
Michigan
 
Count for af = CTOD(' / / ')
Count for af <> CTOD(' / / ')

in DbaseIII+
 
What your wrote should give you the desired results. you are counting for the field "af" to be either blank or not blank.
try this:
count for empty(af)
count for .not. empty(af)


are you not getting the desired counts?

Ali Koumaiha
TeknoSoft Inc.
Michigan
 
count for empty(af)
count for .not. empty(af)
work in my minigui code, but are invalid function in DbaseIII+

Thanks.
 
This was an issue with dBase date comparisons at least up through version 5, the last one I'm familiar with. Comparing to an empty date always returned .F. (false). Why don't you use DTOS() function which typically returns a string in the format "CCYYMMDD"? An empty date yields an empty string and hence can be accurately compared.
Code:
? CTOD(DATE()) = CTOD("  /  /  ")
.F.
? CTOD(DATE()) <> CTOD("  /  /  ")
[COLOR=red][b].F.  && wrong[/b][/color]

? DTOS(DATE()) = DTOS("  /  /  ")
.F.
? DTOS(DATE()) <> DTOS("  /  /  ")
[COLOR=green][b].T.  && correct[/b][/color]
 
I have used an actual date. I use one earlier than possible within the data set. Also, test the month "IF MONTH(DATE()) = 0" should work for you.

Jim C.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top