• 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: deivy petrescu <email@hidden>
  • Date: Wed, 14 Dec 2005 21:37:26 -0500


On Dec 14, 2005, at 19:52, deivy petrescu wrote:


On Dec 14, 2005, at 18:58, Bernard Bernu wrote:

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

I'm hopping something much simple could be done.
Any idea ?

The only operation I found on date is to add or subtract days or integers. Adding month or year seem not to work !

Bernard

Your script fails at the last day of every month with 31 days, except July.
It fails in February as well.
You should check if "adate" is not already at the end of the month.


This scripts checks for all possibilities:

<script>
set l to current date
copy l to m
set day of l to 31
set jour to (31) - (day of l)
if jour > 0 then set {day of m, l} to {jour, m}
return l
</script>


deivy

I am sorry, I fail every end of night. Your script is fine. I did not see the "set day of adate to 1"

deivy

_______________________________________________
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: last day of the month of a date
      • From: "Mark J. Reed" <email@hidden>
References: 
 >last day of the month of a date (From: Bernard Bernu <email@hidden>)
 >Re: last day of the month of a date (From: deivy petrescu <email@hidden>)

  • Prev by Date: Re: last day of the month of a date
  • Next by Date: Re: last day of the month of a date
  • Previous by thread: Re: last day of the month of a date
  • Next by thread: Re: last day of the month of a date
  • Index(es):
    • Date
    • Thread