You are here:

FoxPro/how to get the current date record

Advertisement


Question
Good day sir!

I just wanna ask how can I get a current date record from a table to display on my report, (using VFP9.0)
Say I have:
12/20/2012
12/21/2012
12/29/2012
01/15/2013
How can I display: 01/15/2013 in my report?

Thank you!

Answer
AJ,

  Since displaying dates on a report are the same as any other field, I am guessing that you are interested in either the format or selecting the most recent record.  

For formatting:

    SET DATE controls the order of Month,Day & Year EX:  SET DATE TO MDY
    SET CENTURY dictates the number of digits in the year   EX:  SET CENTURY ON = 4 digits

For record selection:

    The easiest way to insure getting the most recent record is to index the table by the date field, then use the bottom record.  Setting a filter insures it's the only record used.
         INDEX ON <datefield> to TempIDX
         GO BOTTOM
         CurrRec = RECNO()
         SET FILTER TO RECNO() = CurrRec

         [ Run Report ]

         SET FILTER TO
         SET INDEX TO
         DELETE FILE TempIDX.IDX


I hope this covers what you wanted...

FoxPro

All Answers


Answers by Expert:


Ask Experts

Volunteer


Fred Frase

Expertise

Questions about development only. No installation or hardware specific questions, please. Your first step in requesting assistance should be to identify the version of FoxPro you are using. I can write short functions but, PLEASE do not ask me to write programs for you.

Experience

Nearly 30 years professional programming experience using FoxPro (FoxBase through VFP 9) or other xbase language, primarily in Windows environments.

Education/Credentials
Completed a 1,000 hour diploma course in programming at International Academy of Ohio (subsequently merged with Southern Ohio College).

©2016 About.com. All rights reserved.