select statement(Resolved)
hi
I would like to display the invoice between two dates . there are from the starting date to the end date. Please help me in the select statement.
Heres my select statement, but cant works:
rs_rct.Open "Select * from Receipt where DateValue(ReceiptDate) >= '" & DateValue(txtFrom) & "' <= '" & DateValue(txtTo) & "'", con, adOpenKeyset, adLockPessimistic
:blush:
Re: select statement(Resolved)
RobCrombie,
i have no idea why your file "orig and ItsBeenRobbed cant work on my PC.
2 Attachment(s)
Re: select statement(Resolved)
When you say 'cant work on my PC' what exactly happens (or not) ?
The pgm runs I assume ?
Just when you select the date range you don't see all the records you expect ?
I Looked at the solution you last posted, and noticed that you hadn't really solved the International Date settings problem, You had just made individual variations between using DD/MM/YYYY and MM/DD/YYYY in different places in your pgm.
That was not the way to solve this problem, it is just 'band aiding' it.
I have just run your pgm now, and I am attaching the results.
You haven't said which country you are in, but because we are getting mixed results, I can bet it is not Australia.
So you should either move to Australia, or come up with a solution that is 'fool proof'.
I am also attaching the contents of your DB. If you study them you will see that my run of your pgm returns the three records that the system is forced into thinking are Apr or May.
The other two records can be interpreted as being Dec or Nov, and I guess that is what is happening, in an Australian run of your pgm.
You haven't shown the code that was writing the data to the DB. I am guessing that it is not 'date proof'.
As I said in my first post, I am frightened of Dates, and have invented an alternative approach which uses Longs', which is 'fool proof'
I can tell, that you wil not be open to that approach, so instead you should post all of your code, and really l i s t e n to the other experts.
Re: select statement(Resolved)
hi,
i m from Malaysia. i get your point. the only thing is i need to change the format before it display on the grid which i havent done it.
when i run your pgm, i put 03/04/2005 to 30/04/2005, i get the result: 04/04/2005 only
for 10/04/2005 to 30/04/2005 the result is 24/05/2005
the result seems totally out of control.
Re: select statement(Resolved)
Quote:
Originally Posted by vivian2u
hi,
i m from Malaysia. i get your point. the only thing is i need to change the format before it display on the grid which i havent done it.
when i run your pgm, i put 03/04/2005 to 30/04/2005, i get the result: 04/04/2005 only
for 10/04/2005 to 30/04/2005 the result is 24/05/2005
the result seems totally out of control.
Like I said in my post (#40) - formatting of dates for selection is something that has to be worked out and consistently applied. You will go around in circles if you do not have a firm foundation to work with.
You must come up with a format (yyyy-mm-dd or dd mmm yyyy or whatever works with your regional settings and version of DB) - determine that it does work and then consistently apply it in your program. This R&D portion of development cannot be skipped over.
Once you have a format that works, wrap the logic for "formatting" that into a nice FUNCTION buried in a module somewhere - and use that function everywhere for date translation.
We like to have a function that can translate from "stored" format, "selection" format and "display" format - all with the same function - based on a "output type" parameter.
1 Attachment(s)
Re: select statement(Resolved)
The 'system' is playing 'russian roulette' with it's guesses.
You have to make it absolutely 'Fool proof', so it can no longer be allowed to guess.
You haven't jumped to take up my 'Longs approach'.
Thus you should let the experts in handling Dates, have a look.
I'll attach your project(in zip format), so they can more easily open it.
You should also post the code, that will be used to store the dates into the DB, as it is vital that it be 'Date proof', as well.