• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Correcting AGE_INFO
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Correcting AGE_INFO


  • Subject: Re: Correcting AGE_INFO
  • From: "email@hidden" <email@hidden>
  • Date: Thu, 4 Feb 2010 09:56:25 -0800

 Here are two more possible solutions:

CountBusinessDays is shorter and little more intuitive but it does have the disadvantage of numerous calls to calculate dates which will add to the execution time.
CountWeekDays is a few lines longer but only calculates two dates so it should run faster.

I think they're both straightforward enough for a newbie to be able to modify as needed.

HTH,

ES


set startDate to date ("1 - 2 - 2010")
set endDate to date ("3 - 4 - 2010")
set BD to CountBusinessDays(startDate, endDate)
set wd to CountWeekDays(startDate, endDate)
return {BD, wd}

on CountBusinessDays(aDate, endDate)
set dayCount to 0
repeat until aDate > endDate
if weekday of aDate is not in {Saturday, Sunday} then set dayCount to dayCount + 1
set aDate to (aDate + 1 * days)
end repeat
return dayCount
end CountBusinessDays

on CountWeekDays(aDate, endDate)
set dayCount to 0
set dayNumber to weekday of aDate as integer
set totalDays to (endDate - aDate) / days
repeat totalDays times
set dayNumber to dayNumber + 1
if dayNumber = 8 then set dayNumber to 1
-- assumes Sunday is 1, Saturday is 7
if dayNumber is not in {7, 1} then set dayCount to dayCount + 1
end repeat
return dayCount
end CountWeekDays

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Correcting AGE_INFO
      • From: Doug McNutt <email@hidden>
References: 
 >Correcting AGE_INFO (From: Bert Groeneveld <email@hidden>)

  • Prev by Date: Re: Script Menu in 10.6.2
  • Next by Date: Re: Correcting AGE_INFO
  • Previous by thread: Re: Correcting AGE_INFO
  • Next by thread: Re: Correcting AGE_INFO
  • Index(es):
    • Date
    • Thread