I'm trying to retrieve records between two specific dates. The dates in the table from which I'm retrieving the records are expressed in the "dd/mm/yyyy" format, and the condition I'm using is expressed the same.
I've noticed that my code doesn't work as expected, and I discovered that its due to the fact that it reads the date as in US Format rather than in the EU Format. For instance:
SELECT CodOpe, PV_Sensy, Cashflow_Date FROM Amort_Plans_Calc
WHERE Cashflow_Date > #01/04/2018# AND Cashflow_Date <= #01/10/2021#
AND CodOpe = "06340CMLIM00506007228378601";
returns the wrong number of records. If I use this code, instead, it returns the right number:
SELECT CodOpe, PV_Sensy, Cashflow_Date FROM Amort_Plans_Calc
WHERE Cashflow_Date > #04/01/2018# AND Cashflow_Date <= #10/01/2021#
AND CodOpe = "06340CMLIM00506007228378601";
I already set all fields in the right format. I've tried using the Format function within the query condition:
SELECT CodOpe, PV_Sensy, Cashflow_Date FROM Amort_Plans_Calc
WHERE Cashflow_Date > Format("01/04/2018", "dd/mm/yyyy")
AND Cashflow_Date <= Format("10/01/2021", "dd/mm/yyyy")
AND CodOpe = "06340CMLIM00506007228378601";
This method didn't worked neither (it didn't show any result at all).
Consider, also, that I just put it simplier that it actually is, since my real script needs the Dateadd function in the condition (hence my need to have Access correctly read the dates) and should be something like this:
SELECT CodOpe, PV_Sensy, Cashflow_Date FROM Amort_Plans_Calc
WHERE Cashflow_Date > Dateadd("m", 18, Format("01/04/2018", "dd/mm/yyyy"))
AND Cashflow_Date <= Dateadd("y", 5, Format("10/01/2021", "dd/mm/yyyy"))
AND CodOpe = "06340CMLIM00506007228378601";
This version doesn't show any result, but it seems I can't put the hashtags outside the dateadd function.
How can I solve this problem?
Thanks in advance,
Jona
the records are expressed in the "dd/mm/yyyy" formatdoes this mean that the dates are in a text column? - Brad