Reputation: 53
I am trying to compare 4 date fields in my access Database and set the date difference between the latest value and adatum into parkdauer. It works fine for any rows in which the dates are during the same month.
strSQL = "UPDATE Steuerungsboard
SET parkdauer = DateDiff('d', [kspausgang], [adatum])
WHERE FORMAT(kspausgang, 'dd/MM/yyyy') >= FORMAT( iausgang, 'dd/MM/yyyy')
And FORMAT( kspausgang, 'dd/MM/yyyy') >= FORMAT( aausgang, 'dd/MM/yyyy')
And FORMAT( kspausgang, 'dd/MM/yyyy') >= FORMAT( gausgang, 'dd/MM/yyyy');"
CurrentDb.Execute strSQL, FailonError
Thanks for any Help!
Upvotes: 1
Views: 92
Reputation: 32682
Just remove all those FORMAT
things and this will run fine.
The problem with FORMAT is you're actually comparing dates alphabetically, and that's wrong for numerous reasons.
"UPDATE Steuerungsboard
SET parkdauer = DateDiff('d', [kspausgang], [adatum])
WHERE kspausgang >= Nz(iausgang)
And kspausgang >= Nz(aausgang)
And kspausgang >= Nz(gausgang);"
Upvotes: 5