Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding the payperiod that included 12th of month
Message
From
17/07/2006 19:25:30
 
 
To
17/07/2006 19:21:42
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01137078
Message ID:
01137102
Views:
17
>>>>>So... let me think. Q&D solution:
>>>>>
>>>>>
* try with 12th of the first date's month
>>>>>d12=date(year(d1), month(d1), 12)
>>>>>*-- if first date is past 12th, use 12th of the second date
>>>>>if d12<d1
>>>>>  d12=date(year(d2), month(d2), 12)
>>>>>endif
>>>>>scan for between(d12, d1, d2)
>>>>>  && do stuff here
>>>>>endscan
>>>>
>>>>I think this would work (uses Julian date):
>>>>
>>>>
BETWEEN(SYS(11,DATE(YEAR(PpBeg),MONTH(PpBeg),12)),SYS(11,PpBeg),SYS(11,PpEnd)) ;
>>>   OR BETWEEN(SYS(11,DATE(YEAR(PpEnd),MONTH(PpEnd),12)),SYS(11,PpBeg),SYS(11,PpEnd))
>>>
>>>I was also tempted to make it a one-liner but resisted it for clarity's sake. Payroll report never hinges on a couple of milliseconds more or less.
>>
>>I didn't realize how big this would be until after I posted it. I built it up with a cut & paste of the two parts. Thanks for making it more readable.
>
>As we said in some other thread once, readability is in the eye of the beholder :).
>
>
between(date(year(iif(day(d1)<=12, d1, d2)), month(iif(day(d1)<=12, d1, d2)), 12), d1, d2)
>is an equivalent one-liner I had in mind... which I wouldn't like to see in my code. Just a matter of taste.

I agree, I probably would have done it differently for my code, too. I'd of at least used variables for the PpBeg/PpEnd Julian numbers.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Previous
Reply
Map
View

Click here to load this message in the networking platform