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

  • Home
  • SEARCH
  • 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 668265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:01:15+00:00 2026-05-14T00:01:15+00:00

I’m building an NSPredicateEditor , and I want the ability to do advanced date

  • 0

I’m building an NSPredicateEditor, and I want the ability to do advanced date comparison.

I realize that I can build an NSPredicateEditorRowTemplate with a rightExpressionType of NSDateAttributeType, but the predicates I want to build need to be much more advanced than that.

For example, I need to basic comparison like:

  • dateKeypath < aDate
  • dateKeypath <= aDate
  • dateKeypath = aDate
  • dateKeypath != aDate
  • dateKeypath > aDate
  • dateKeypath >= aDate

These basic comparisons are quite easy to achieve, and I have these working. However, I also need to do comparisons like:

  • dateKeypath isInTheLast n days (or weeks, months, years)
  • dateKeypath isNotInTheLast n days (or weeks, months, years)
  • dateKeypath between aDate and anotherDate

How can I achieve these sorts of comparisons? I understand that I’ll need to create a custom NSPredicateEditorRowTemplate, but I haven’t found any clear documentation on how to achieve something like this.

EDIT
Bonus points are available for also knowing how to make these comparisons a full date-time (year-month-day-hour-minute-second) comparison (as NSDateAttributeType only has year-month-day granularity).

  • 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-05-14T00:01:16+00:00Added an answer on May 14, 2026 at 12:01 am

    In retrospect, this answer seems somewhat obvious:

    I actually described 3 predicate editor row templates, not one. The three templates are:

    • dateKeyPath [<, <=, =, >, >=, !=] [NSDatePicker]
    • dateKeyPath [inTheLast, notInTheLast] [NSTextField] [NSPopUpButton]
    • dateKeyPath [between] [NSDatePicker] "and" [NSDatePicker]

    If you build these three predicate editor row templates and give them to the predicateEditor, the editor will realize that they’re all using the same dateKeyPath, and display then crunch all their operators into a single popup button. It will then switch out the actual views to the right of the operator depending on which operator is selected.

    Edit

    For bonus points: you can modify the precision of the date pickers by overriding the templateViews method, retrieving the templateViews from super, and setting the datePickerElements on the appropriate pickers.

    Edit 24 Nov 2010

    For anyone who comes across this again, I’ve written a couple blog posts on creating custom NSPredicateEditorRowTemplates:

    • Creating a simple NSPredicateEditorRowTemplate
    • Creating an advanced NSPredicateEditorRowTemplate (this one shows how to do the inTheLast and inTheNext row template)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported

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.