[Solved] How do i use a criterion of today minus 7 days in base query?

Creating tables and queries
Post Reply
guff54
Posts: 4
Joined: Sat Sep 10, 2022 12:27 am

[Solved] How do i use a criterion of today minus 7 days in base query?

Post by guff54 »

I have a table that includes dates of action items but they do not need to be address until they are 7 days old. I am trying to create an editable query that returns only qualified records of today minus 7 days. I have tried Now() -7 but it doesn't work. Any help would be great or other ways to accomplish the same goal thats automated. Thanks!
Last edited by guff54 on Sun Sep 11, 2022 4:57 pm, edited 1 time in total.
LibreOffice 7.3.2.2 on macOS 12.5.1
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How do i use a criterion of today minus 7 days in base query?

Post by Villeroy »

IF you are using embedded HSQL (see status bar), that database is documented here: http://www.hsqldb.org/doc/1.8/guide/ch09.html
It comes with DATEDIFF which calculates a number from 2 dates.

Code: Select all

SELECT * FROM "table" WHERE DateDiff('dd', "DateColumn", CURRENT_DATE)<8
Unfortunately, that version of HSQL does not include DATEADD which would calculate a date from another date and a number.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
guff54
Posts: 4
Joined: Sat Sep 10, 2022 12:27 am

Re: How do i use a criterion of today minus 7 days in base query?

Post by guff54 »

Thanks Villeroy!! That did the trick. I appreciate you!
LibreOffice 7.3.2.2 on macOS 12.5.1
Post Reply