Skip to content

Instantly share code, notes, and snippets.

@hugithordarson
Last active November 4, 2021 10:41
Show Gist options
  • Save hugithordarson/c97ec7b15b29db8912506db75af9f412 to your computer and use it in GitHub Desktop.
Save hugithordarson/c97ec7b15b29db8912506db75af9f412 to your computer and use it in GitHub Desktop.
void performFetch() {
addDateTruncAttribute( editingContext, "SomeEntity", "checkInTimeTruncated", "check_in_time" );
addDateTruncAttribute( editingContext, "SomeEntity", "requestedTruncated", "requested" );
EOQualifier q = EOQualifier.qualifierWithQualifierFormat( "checkInTimeTruncated>=requestedTruncated", null );
// ...finish your fetch using the qualifier
}
static void addDateTruncAttribute( EOEditingContext ec, String entityName, String attributeName, String columnName ) {
EOAttribute attribute = new EOAttribute();
attribute.setName( attributeName );
attribute.setColumnName( columnName );
attribute.setReadFormat( "date_trunc('day',%P)" );
EOUtilities.entityNamed( ec, entityName ).addAttribute( attribute );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment