Help with WHERE clause syntax in SQL

Creating tables and queries
Post Reply
JWB23
Posts: 9
Joined: Wed Jun 20, 2018 12:02 am

Help with WHERE clause syntax in SQL

Post by JWB23 »

Hi,

I need help with my WHERE clause syntax. I’m looking to return rows that have a certain date that’s older than a month.

Example:

SELECT…
WHERE tbl_date < CURRENT_DATE – 30 DAYS

I’ve tried no less than 8,000 variations of this, but always got an SQL error along with a very unhelpful message. Any ideas?

Thanks
OpenOffice 4 on Windows 10
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Help with WHERE clause syntax in SQL

Post by FJCC »

Try

Code: Select all

WHERE DATEDIFF('dd', tbl_date, CURRENT_DATE) > 30
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Help with WHERE clause syntax in SQL

Post by Villeroy »

If the status bar of your database document window looks like this ...
Image
... then your database is HSQL 1.8 which is documented here: http://www.hsqldb.org/doc/1.8/guide/ch09.html
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
Post Reply