• 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 of next Thursday
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date of next Thursday


  • Subject: Re: Date of next Thursday
  • From: Paul Berkowitz <email@hidden>
  • Date: Wed, 15 Nov 2000 10:29:37 -0800

On 11/15/00 9:46 AM, "Dave Balderstone" <email@hidden> wrote:

> Is there an easy method to get the date of next Thursday in a script
> without a lot of if/thens?
>
> I'm working on a script to change folio dates in Xpress templates,
> and rather than relying on a user to enter the correct date, I'd like
> to be able to have the script say, in essence, "If (current date) is
> Friday, December 29, 2000 then next Thursday will be January 4, 2001"
> store that into a variable so I can extract the info I need.
>
You probably don't want the _full_ current date, right? (date "Friday,
December 29, 2000 3:54:06 PM") Just the date string, yes? It's easy if you
have OS 8.6 or higher. Now, do you mean by "next Thursday" - "the very next
Thursday to come, even if it's this week", as they do in the UK (so that
"next Thursday" means "in two days" if it happens to be Tuesday today)? Or
do you mean "Thursday of next week", as in the US (so that "next Thursday"
means "in nine days" if it happens to be Tuesday today).

UK version:

--------
set today to weekday of (get current date)

set theWeekdays to {Wednesday, Tuesday, Monday, Sunday, Saturday, Friday,
Thursday}
repeat with i from 1 to 7
if today is item i of theWeekdays then
set nextThursday to date string of ((current date) + (i * days))
exit repeat
end if
end repeat
nextThursday
--"Thursday, November 16, 2000"

---------------------------

US version (where Sunday is the first day of the week):

set today to weekday of (get current date)

set theWeekdays to {Saturday, Friday, Thursday, Wednesday, Tuesday, Monday,
Sunday}
repeat with i from 1 to 7
if today is item i of theWeekdays then
set nextThursday to date string of ((current date) + ((i + 4) *
days))
exit repeat
end if
end repeat
nextThursday
--"Thursday, November 23, 2000"

------------------------------------------

If you like "next week" beginning on Monday, not Sunday, then use this

US version (where Monday --is the first day of the week):

set today to weekday of (get current date)

set theWeekdays to {Sunday, Saturday, Friday, Thursday, Wednesday, Tuesday,
Monday}
repeat with i from 1 to 7
if today is item i of theWeekdays then
set nextThursday to date string of ((current date) + ((i + 3) *
days))
exit repeat
end if
end repeat
nextThursday
--"Thursday, November 23, 2000"


--
Paul Berkowitz


  • Follow-Ups:
    • Re: Date of next Thursday
      • From: Allen Watson <email@hidden>
    • Re: Date of next Thursday
      • From: Dave Balderstone <email@hidden>
References: 
 >Date of next Thursday (From: Dave Balderstone <email@hidden>)

  • Prev by Date: Auto. Quit Netscape?
  • Next by Date: RE: Date of next Thursday
  • Previous by thread: Date of next Thursday
  • Next by thread: Re: Date of next Thursday
  • Index(es):
    • Date
    • Thread