×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Finding a value in effect on a given date withing a date indexed field

Finding a value in effect on a given date withing a date indexed field

Finding a value in effect on a given date withing a date indexed field

(OP)
I am working in Dbase and need a solution for finding a record in a database that is indexed on a date field within the database. The database tracks changes to the valuation of a given piece of equipment. Changes to the valuation may or may not occur on a consistent basis. I need to search the database and a return the corresponding valuation that was in effect on that date. The date may or may not be an exact match and the index is on the dates of that the value changed. What code can I use to simplify finding the value that was in existence on a day that there isn't a corresponding match to a date within the database as the FIND command will not find the record? All help is appreciated, thanks

RE: Finding a value in effect on a given date withing a date indexed field

I haven't used FIND for a long time and so I'm not sure of the syntax, I used SEEK() instead with dBase 5 for DOS. Since it wouldn't work with Windows versions after XP I converted code and upgraded completely to Visual FoxPro 9.

During the SEEK only, would SET NEAR ON work? You might also need SET EXACT OFF in case you have more than the one field in the index or, for example, in case you want to seek by only part of the date such as by year+month or year only. Also experiment with DESCENDING order in case that helps, indexes default to ASCENDING order. Between those three commands you should find a way for it to work.

One final thought. When building evaluated indexes combining multiple items you can use DTOS(DateField) since VFP requires all data types converted to character types in the index expression.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close