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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using dates and parameters in views

Status
Not open for further replies.

trimtrom

Programmer
Dec 12, 2003
35
0
0
GB
Hi,
i am a Foxpro 6.0 beginner and I am trying to use a database view. I am trying to create a filter using a date field and am having enormous problems.

I am trying to select records equal to a date in a view parameter (?paradate is the name) and I find I cannot use the = sign in creating the filter. An empty recordset is returned. The same using the < sign. However, using the > sign, all the records in the table are returned! I am obviously not treating the date field or the parameter correctly, and I would be grateful if someone could show me how to create a view filter based on this date field.

Many thanks,
Trimtrom
 
HI

Assuming 'paradate' is a Date format variable, and the field is also a date format variable, the following should work correctly..

SELECT * FROM myDbf ;
WHERE DTOS(paradate) == DTOS(myFieldDate)

If you have used an index on date, DTOS(myFieldDate) is the recommended way to index.

You can very well use date variable, but when you pass it make sure that the date variable goes as date variable and compared as date variable against the date type field.

Quite often the passing could be as character type. So if paradate is a charater type field, then you should code..
SELECT * FROM myDbf ;
WHERE paradate == DTOS(myFieldDate)
Make sure the paradate in this case is in "YYYYMMDD" format and not in any date format of your choice.

:)

____________________________________________
ramani - (Subramanian.G) :)
 
Thanks for the above.

In the end I found that I had to format the date strictly in the format {^yyyy-mm-dd}, or otherwise I had to SET STRICTDATE TO 0 to stop strict comparison.

Thanks for your help,

Trimtrom

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top