Getting Week Ending information

A customer asked me recently about how to build a FoxPro expression that would give them a string like 21/08 for the week ending based on a 7 day week.

Using DOW , this is fairly easy;

? PADL(MONTH(DATE()-DOW(DATE())+1),2,’0′) + “/”+PADL(DAY(DATE()-DOW(DATE())+1),2,’0′)

Why do the +1? Because DOW() gives you the day of the week and by subtracting the DOW ( ) would take you to the end of the previous week.

Now, if you’re sorting by this, you’ll see I use the PADL so that it always put a zero in front of any single digit months (01 for January, etc).

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Contact

48 Stonemeadow Drive
Kanata, Ontario K2M2K2

+1 613-851-4496 Contact Us

Connect

Newsletter

Coming Soon