• 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: last day of the month of a date
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: last day of the month of a date


  • Subject: Re: last day of the month of a date
  • From: Bernard Bernu <email@hidden>
  • Date: Thu, 15 Dec 2005 12:37:00 +0100


Le 15 déc. 05, à 12:29, Nigel Garvey a écrit :

Bernard Bernu wrote on Thu, 15 Dec 2005 00:58:06 +0100:

I'd like to get the last day of the month of a date, say current date.
The only "simple" way I found to get it is : (here adate is a valid
date)

		copy adate to newdate
		set day of newdate to 1
		set newdate to newdate + 31 * days
		set day of newdate to 1
		set newdate to newdate - 1 * days

You can also set the day to 32 to overflow into the following month. The
day of the resulting date is the number of days overflowed:


  copy adate to newdate
  set day of newdate to 32
  set newdate to newdate - (day of newdate) * days
Thanks for this clever trick.

Bernard

Or:

copy adate to newdate
set newdate's day to 32 - ((adate + (32 - (adate's day)) * days)'s day)


Or, just to keep Gary amused:  ;-)

tell (adate + (32 - (adate's day)) * days) to set newdate to it - (its
day) * days



NG

_______________________________________________
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

Bernard

_______________________________________________
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: 
 >Re: last day of the month of a date (From: "Nigel Garvey" <email@hidden>)

  • Prev by Date: Re: last day of the month of a date
  • Next by Date: Re: Set hours of date = stack overflow error on 10.3.9?
  • Previous by thread: Re: last day of the month of a date
  • Next by thread: Set hours of date = stack overflow error on 10.3.9?
  • Index(es):
    • Date
    • Thread