Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:32:21+00:00 2026-06-15T11:32:21+00:00

In my local database, I have a list of NSTimeInterval values saved. I have

  • 0

In my local database, I have a list of NSTimeInterval values saved.
I have to find out and fetch all records available in a given Month. The only problem is in fetching records for last day of the given month seems to be unavailable.

Lets say given month is December so I have to fetch all the records from 1st Dec to 31st Dec (Till 11:59PM)

I am using following implementation:

[self.dateFormatter setDateFormat:@"dd-MM-yyyy"];
NSDate *startDate = [self.dateFormatter dateFromString:@"1-12-2012"];
NSDate *endDate = [self.dateFormatter dateFromString:@"31-12-2012"];

NSTimeInterval startDateTimeInterval = [startDate timeIntervalSince1970];
NSTimeInterval endDateTimeInterval = [endDate timeIntervalSince1970];

[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"(mdate >= %f) AND (mdate <= %f)",startDateTimeInterval,endDateTimeInterval]];

I have noticed that endDateTimeInterval double value is pretty less as compared to saved value in the database for 31st (9AM). But howz it possible, I am expecting my endDateTime should be till 31st Dec 11:59 PM.

Please provide your inputs on this issue.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:32:22+00:00Added an answer on June 15, 2026 at 11:32 am

    The NSDate objects you are creating implicitly have a time of 00:00. So the predicate search will not include the last day from time 00:01 to 23:59. The easiest change is to set the end date to the next day (first of next month) and change the predicate to a less than, instead of less than or equal.

    [self.dateFormatter setDateFormat:@"dd-MM-yyyy"];
    NSDate *startDate = [self.dateFormatter dateFromString:@"1-12-2012"]; // start of range, inclusive
    NSDate *endDate = [self.dateFormatter dateFromString:@"1-1-2013"]; // end of range, exclusive
    ...        
    [fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"(mdate >= %f) AND (mdate < %f)",startDateTimeInterval,endDateTimeInterval]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of items which is fetched from the local database. Every
I have a local list of values that I need to have entity framework
I have a local Database running on localhost:3306, which I access with MySQL Workbench.
I have searched inoformation to how attach local database to the IPA file to
I am developing an android application in which i have a local database.I want
I would like to develop an Android application which will have a local database.
I have built a local DVD Database using Codeigniter, With film names etc in.
I have shared hosting on CentOS with local MySQL database. I'm able to run
I have been experimenting with writing applications that use a local SQL Database to
I have a database in my local machine. I have a C# application that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.