Hi
You can use 2 queries as in this AddOneDay.odb example.
-
Query1
selects the records according to the parameter and create a new column by adding one day to the date
-
Query2
counts records from Query1
and display the 2 dates
Query1
SELECT "Date", TO_CHAR( CAST( YEAR( "Date" ) || '-' || MONTH( "Date" ) || '-' || DAY( "Date" ) + 1 AS "DATE" ), 'DD/MM/YYYY' ) "Date+1"
FROM "Table" WHERE "Date" = :Start_Date
Explanations:
- the date is split by year, month, day so you can do
DAY( "Date" ) + 1
-
CAST
converts the expression to DATE format (which is a number)
-
TO_CHAR
displays the date in the format of your choice. My interface is in French, so I use ‘DD/MM/YYYY’
Query2
SELECT "Date", MAX( "Date+1" ) "Date + 1", COUNT( "Date+1" ) "Count" FROM "Query1" GROUP BY "Date"
Explanations:
- Use of
GROUP BY
to be able to COUNT
- Fields used in a “group” query must all apply a function. I use
MAX( "Date+1" )
to display this field. Note that “Date+1” is the name of the fied; it is a string, not the formula (calculation is made in Query1
)
To test, run Query2
with parameter 30/06/08 (once again my UI is french, adapt if necessary, i.e. MM-DD-YYYY).
The result is 3 for 01/07/2008
Regards