Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Date arithmetic #347

Closed
davidbilge opened this issue Feb 23, 2013 · 10 comments
Closed

Implement Date arithmetic #347

davidbilge opened this issue Feb 23, 2013 · 10 comments
Milestone

Comments

@davidbilge
Copy link

@davidbilge davidbilge commented Feb 23, 2013

Currently, it is not possible to do date arithmetic in QueryDSL (see http://stackoverflow.com/q/15026895/537738).

Please add support for some functions like adding intervals (sysdate + 10 days) or subtract dates (SELECT * FROM entity WHERE entity.created < (sysdate - entity.delayInDays)). That would be great!

@timowest
Copy link
Member

@timowest timowest commented Feb 25, 2013

Support is now available via the SQLExpressions.addYears, addMonths, addDays, addHours, addMinutes and addSeconds methods.

e.g. SQLExpressions.addDays(dateField, 10);
@davidbilge
Copy link
Author

@davidbilge davidbilge commented Feb 25, 2013

Wow, that was really fast. Is it possible to predict in which version this will surface?

@timowest
Copy link
Member

@timowest timowest commented Feb 25, 2013

3.0.0 will be out in a couple of weeks.

Here is temporary solution

DateTemplate.create(Date.class, "{0} + {1s}", dateField, ConstantImpl.create(2));

which would dateField plus 2 days.

@TuomasKiviaho
Copy link
Contributor

@TuomasKiviaho TuomasKiviaho commented Feb 27, 2013

Would it be possible to add casts between date/time/timestamp as well (not exactly arithmetic I know). It's quite common to have to strip down time part from timestamp and closest thing I found from stackoverflow was to do it via stringValue() which isn't that efficient. This might be already possible in more generic way but I doubt it since there is castToNum(). Would a Sledge Hammer style I-Know-What-I'm-Doing type of blind casting be even possible.

@timowest
Copy link
Member

@timowest timowest commented Feb 27, 2013

@TuomasKiviaho could you create a new ticket for this and maybe add some syntax examples?

@FagnerMartinsBrack
Copy link

@FagnerMartinsBrack FagnerMartinsBrack commented Feb 27, 2013

Needless to say but please create a changelog if any documented feature is going to be broken in a major version pump 😄

@timowest
Copy link
Member

@timowest timowest commented Feb 27, 2013

@FagnerMartinsBrack this is a new feature, or are you concerned about another feature?

@FagnerMartinsBrack
Copy link

@FagnerMartinsBrack FagnerMartinsBrack commented Feb 27, 2013

No specific feature I am concerned.
I saw you mentioning v3 so the first thing I thought was backward compatibility. But thinking better the framework has no reason to change too much except for resource names (which can be easly changed) right?

@timowest
Copy link
Member

@timowest timowest commented Feb 27, 2013

3.0 has a few changes, but those will all be documented in the release notes and most of them can be resolved via a few naming changes.

@timowest
Copy link
Member

@timowest timowest commented Mar 21, 2013

Released in 3.0.0

@timowest timowest closed this Mar 21, 2013
@timowest timowest added this to the 3.0.0 milestone Apr 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants