• 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: Subtract 1 month from date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Subtract 1 month from date


  • Subject: Re: Subtract 1 month from date
  • From: Nigel Garvey <email@hidden>
  • Date: Thu, 9 Dec 2004 01:55:52 +0000

Eric Geoffroy wrote on Wed, 08 Dec 2004 15:37:21 -0800:

>
>Or 4 weeks I suppose. It's okay if it's not super precise.
>
>I can say "d + 4 * weeks"
>but it won't allow "d + 1 * months
>and won't allow d - 1 * weeks
>
>Output should look like this.
>
>11/1/2004...12/1/2004

  on addCalendarMonths(theDate, m) -- m negative for subtractions
    copy theDate to newDate
    set {y, m} to {m div 12, m mod 12}
    if m < 0 then set {y, m} to {y - 1, m + 12}
    set newDate's year to (newDate's year) + y
    if m is not 0 then tell newDate to set {day, day} to {32 * m, day}
    if newDate's day is not theDate's day then set newDate to newDate -
(newDate's day) * days

    return newDate
  end addCalendarMonths

  on USshortDate(theDate) -- no leading zeros/US format
    set {year:y, day:d} to theDate
    copy theDate to b
    set b's month to January
    set m to (b - 2500000 - theDate) div -2500000

    return (m as string) & "/" & d & "/" & y
  end USshortDate

  set endDate to (current date)
  set endDate's day to 1
  set startDate to addCalendarMonths(endDate, -1)
  set searchrange to USshortDate(startDate) & "..." & USshortDate(endDate)


NG
 _______________________________________________
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

  • Follow-Ups:
    • Re: Subtract 1 month from date
      • From: Mr Tea <email@hidden>
  • Prev by Date: "postit" in Satimage osax...
  • Next by Date: Re: Indexing the month
  • Previous by thread: Re: Subtract 1 month from date
  • Next by thread: Re: Subtract 1 month from date
  • Index(es):
    • Date
    • Thread