Base: Query date criteria

I need to make a query using the last 365 days as date criteria. In MS Access I used:

Between Date() And Date()-364

I’ve been googling for a while but can’t find the correct syntax to use in Base. Thanks

First, which database are you using? This is very important as it determines how/what can be done… Also, what are actually looking for? Seems like a query looking for dates which are within the last year.

Using HSQLDB. Yes, dates within last year, but not current year. If I run the query today, I want records dated 12/21/2017-12/20/2018, not records in 2018.

Is that the HSQLDB embedded or are you using a newer external version and which one. The embedded version is very old (v1.8), has little in the way of date functions and is being replaced by Firebird 3.0 embedded.

Just realized, have just answered that already in a previous question.

You may wish to try Firebird. From menu ``Tools->Optionsthe underLibreOffice->Advancedselect (checkbox)Enable experimental options`. Then when you create a new database (will also convert existing in most cases) the default will be Firebird. HSQLDB is still available in the dropdown.

Will continue to muster up some SQL for you using HSQLDB.

@Ratslinger you are a godsend! I’ll try out Firebird since that sounds like that’s the direction to go in. Thanks also for your solution below. I’ll give that a try later when I have time and will follow up at that time.

Hello,

This may be the easiest solution:

Select * from YOUR_TABLE where DATEDIFF('dd', YOUR_FIELD_NAME, CURRENT_DATE) < 365

If this answers your question please tick the :heavy_check_mark: (upper left area of answer). It helps others to know there was an accepted answer.

Thanks! After adding double-quotes around my field name it worked perfectly!