Date math again...

Joe Chasan joe at magnatechonline.com
Wed Jan 4 13:01:00 PST 2006


On Wed, Jan 04, 2006 at 02:07:08PM -0500, Butch Ammon wrote:
> Good afternoon,
> 
> I have another question regarding dates, calculations, and taking into account 
> weekend dates.  Isn't there a simple way of doing this?
> 
> Example:
> 
>   If:
> Then: dd = (10 - 9)
>   If:
> Then: Show "@This is the total number of days " < dd
>   If:
> Then: end
> 
>   Field 9 is the date when the order was entered (i.e.. 12/06/05)
>  Field 10 is the date when the order was shipped (i.e.. 12/21/05)
> 
> Dummy field "dd" comes up saying 15 for the total number of days, which is 
> correct.  **BUT** what about weekends?  It counted Dec 10th, 11th, and also Dec 
> 17th and 18th as work days!  Technically, dummy field "dd" should be: 11 days.
> 
> My main question:  Does anyone have a quick and easy method of doing date math 
> and taking into consideration the weekends inbetween the two dates?

because filepro has the DOW function, its pretty easy to do - off the
top of my head...

then:gosub getdays:

getdays:if:
      then: declare local temp_date(8,mdy/); temp_date=9; dd="0"
dyloop :if: temp_date ge 10
      then: return
       :if: not ("SATSUN" co dow(temp_date,"1"))
      then: dd=dd+"1"
      then: temp_date=temp_date+"1"; goto dyloop
 
about 2 days after you finish putting this on-line, your boss will ask
you "But what about holidays?"  Alas, there is no easy standard for this.
you'd be best-off creating a holidays file, listing in it each date your
company badges a non-work holiday.  using the above method, instead of
a straight calculation (which is also possible), gives you the opportunity 
of doing lookups mid-loop of "temp_date" to this 2nd file.

--- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---
-Joe Chasan-                      Magnatech Business Systems, Inc.
joe at magnatechonline.com           Hicksville, NY - USA
http://www.MagnatechOnline.com    Tel.(516) 931-4444/Fax.(516) 931-1264


More information about the Filepro-list mailing list