• 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: Date computation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date computation


  • Subject: Re: Date computation
  • From: deivy petrescu <email@hidden>
  • Date: Fri, 7 Jan 2005 22:17:11 -0500


On Jan 7, 2005, at 3:18 AM, Michelle Steiner wrote:

I've run into a brick wall here. I'm trying to compute the date of the second Wednesday of the current month, and if the current date is later than or equal to that date, then compute the date of the second Wednesday of the following month.

-- Michelle

-- Support our troops. Bring them home NOW!

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


I know I am jumping in a bit late but I need to oil my joints. It is not as cool as Nigel's, which is really cool.

This script does what was requested, but one might change the weekday and which week of the month is the one the we are interested.

<script>
set tr to run script (text returned of (display dialog "Which day of the week?" default answer "Wednesday" giving up after 6))
set ww to (text returned of (display dialog "Which week of the month 1,2,3,4 ?" default answer "2" giving up after 5))
set hoje to day of (current date)
set cd to "" & 1 + (ww - 1) * 7
repeat while (weekday of (date cd)) is not tr
set cd to "" & (cd + 1)
end repeat
if hoje ≤ cd then return display dialog "It will come in " & cd - hoje & " day(s)"
if day of ((date cd) + (6 - ww) * weeks) ≥ (1 + (ww - 1) * 7) then
display dialog "It will come in " & (5 - ww) & " week(s) and " & 7 + cd - hoje & " day(s)"
else
display dialog "It will come in " & (6 - ww) & " week(s) and " & 7 + cd - hoje & " day(s)"
end if
</script>



By the way there are months with 5 Wednesdays, but they are not consecutive.



Regards Saudações

deivy petrescu
http://www.dicas.com/

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Date computation (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Reading a pdf text file
  • Next by Date: Fetch
  • Previous by thread: Re: Date computation
  • Next by thread: Re: Date computation
  • Index(es):
    • Date
    • Thread