Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use as: I am giving only algorithm/idea.</p> <p>Create stringDate convert to NSDate</p> <pre><code>NSString *range1StartString=@"01/01/05"; NSString *range1EndString=@"01/24/10"; NSString *range2StartString=@"01/25/10"; NSString *range2EndString=@"09/27/10"; NSString *range3StartString=@"09/28/10"; NSString *range3EndString=@"09/30/11"; NSString *range4StartString=@"10/01/11"; NSString *range4EndString=@"01/01/50"; NSString *yourStart=@"01/01/10"; NSString *yourEnd=@"01/31/10"; NSDateFormatter *dateFormatter=[NSDateFormatter new]; [dateFormatter setDateFormat:@"MM/DD/yy"]; NSDate *start1Date=[dateFormatter dateFromString:range1StartString]; NSDate *end1Date=[dateFormatter dateFromString:range1EndString]; NSDate *start2Date=[dateFormatter dateFromString:range2StartString]; NSDate *end2Date=[dateFormatter dateFromString:range2EndString]; NSDate *start3Date=[dateFormatter dateFromString:range3StartString]; NSDate *end3Date=[dateFormatter dateFromString:range3EndString]; NSDate *start4Date=[dateFormatter dateFromString:range4StartString]; NSDate *end4Date=[dateFormatter dateFromString:range4EndString]; NSDate *yourStartDate=[dateFormatter dateFromString:yourStart]; NSDate *yourEndDate=[dateFormatter dateFromString:yourEnd]; </code></pre> <p>After this a long process to check for range </p> <pre><code> //below will find the range for 1. //1. yourStartDate to start1Date will give negative or positive, discard the negative //2. yourEndDate to end1Date will give you again -ive or +ve, do same. //3. Add above +ve values. </code></pre> <p>use this method of check if two dates are in range and get the days between them.</p> <pre><code>-(NSInteger)daysBetweenTwoDates:(NSDate *)fromDateTime andDate:(NSDate*)toDateTime{ NSDate *fromDate; NSDate *toDate; NSCalendar *calendar = [NSCalendar currentCalendar]; [calendar rangeOfUnit:NSDayCalendarUnit startDate:&amp;fromDate interval:NULL forDate:fromDateTime]; [calendar rangeOfUnit:NSDayCalendarUnit startDate:&amp;toDate interval:NULL forDate:toDateTime]; NSDateComponents *difference = [calendar components:NSDayCalendarUnit fromDate:fromDate toDate:toDate options:0]; return [difference day]+1;//+1 as if start and end both date are same, so 1 day worked. } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload