• 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
[SOLVED] Re: Getting the last date of the month?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] Re: Getting the last date of the month?


  • Subject: [SOLVED] Re: Getting the last date of the month?
  • From: Nick Zitzmann <email@hidden>
  • Date: Tue, 20 Mar 2007 13:52:41 -0600


On Mar 20, 2007, at 11:51 AM, Greg Titus wrote:

If you are starting with the first day of the month, as your "firstDayOfMonth" variable name suggests, then you ought to be able to add one month and subtract one day to get the last day of the month. Untested, written in Mail, but something like:

dateComponents = [[NSDateComponents alloc] init];
[dateComponents setMonth:1];
[dateComponents setDay:-1];
lastDayOfMonth = [calendar dateByAddingComponents:dateComponents toDate:firstDayOfMonth options:0];
[dateComponents release];

Thanks Greg; this solution works.

Of course, it also assumes that time has no end... But I think I'm going to stay out of that philosophical discussion. :)

Nick Zitzmann
<http://www.chronosnet.com/>


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Getting the last date of the month? (From: Nick Zitzmann <email@hidden>)
 >Re: Getting the last date of the month? (From: Greg Titus <email@hidden>)

  • Prev by Date: Re: CoreData, Faulting, and KVO
  • Next by Date: Re: NSString encoding problem with extended characters ( AKA : converting NSString to std::string)
  • Previous by thread: Re: Getting the last date of the month?
  • Next by thread: Re: Background if Login Item launched
  • Index(es):
    • Date
    • Thread