Вопрос

I've been searching the web and asked around, but can't seem to find an answer to my problem...

I have a running ODBC connection with my FrontBase database in OpenOffice Base. I manage to select everything I want, but when I only want to show the records between certain dates, or even one date I keep on getting a Semantic Error.

Here's my query:

SELECT * FROM "SALES" WHERE "DATE" = '2014-04-01'

Just in case you suggest using # for the date, it doesn't work either

DATE '2014-04-01' is also unsuccessful :(

Anyone have any ideas?

Это было полезно?

Решение

After a lot of trial and errors I took a closer look at the OpenOfficeBase interface. I was sure nothing was wrong with my statement so there must be something in Base that I'm missing.

In the toolbar there's a button with SQL and a checkmark which says "Execute SQL-command immediatly". Thought it wouldn't do any harm if I enabled it and gave it a try. And there it was, my query with date filter! I have no idea why that button is there or what it's exact function is, but enabling it made my query work.

enter image description here

Thanks anyway for the suggestions, but apparently we've got to look further than just the language ;-)

Другие советы

A shot in the dark here. Youŕe using a FrontBase database, googling on "Frontbase select date range" gave me this page: http://www.frontbase.com/documentation/LookSeeIntro-2.3.html

There they have this example query:

SELECT
   receiver FROM memo_mails 
WHERE 
   sender = 'QA' AND 
   CAST(dateSent AS DATE) < DATE '2001-06-01' AND
   SATISFIES(quickx, 'Periscope & invoice');

So based on that example, I would try

SELECT
    * FROM "Sales"
WHERE
    (CAST("Sales"."SalesDate" AS DATE) >= DATE '2014-06-01') AND
    (CAST("Sales"."SalesDate" AS DATE) <= DATE '2014-06-30');
SELECT * FROM SALES WHERE DATE = '2014-04-01'

The above should work as long as there is no time in the column you are trying to select from. Whats the columns data type?

If you're still looking for answers

SELECT * FROM "SALES" WHERE "DATE" = {D '2014-04-01'}

It seems that one should put the letter D to signify that it is a date and not a string/varchar. I hope this helps, even though the question is 1 year old.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top