please guys, i need an sql query to select data from an access database using vb6. the query will only provide current date and the filed been compaired is curr_date in the database.
for example
SELECT *
FROM TABLE
WHERE curr_date BETWEEN firstoflastmonth AND endoflasthmonth;
SELECT *
FROM TABLE
WHERE curr_date BETWEEN firstoflastweek AND endoflasthweek;
SELECT *
FROM TABLE
WHERE curr_date BETWEEN firstofthismonth AND endofthismonth;
SELECT *
FROM TABLE
WHERE curr_date BETWEEN firstofthsiweek AND tilldate;
The problem i have figuring ot is how to specify the two dates in comparison
Is it not easiest to just check wich month/week you want it to be in then?
From you examples:
This would become (with the month function used)
This compares the month of your curr_date to the month of Date (the current date) minus one month, so the last month.
This can also be done using datediff:
The last line is added to make sure that dates one month later are not selected.
Same thing can be applied to the other queries using the date function found here
Links used to the reference sheet provided by Richard Calahan