I’m trying to get a date in my database but when the day is less than 12, the month and the day are switched
Example: In the database 2012-02-10 (2 october 2012), the value I get when I do that:
lastDateMill = Nz(DLookup("LastContactDate", "Mills", "MillID = " & lstMills.Column(0, i)), 0)
is
lastDateMill = "10/02/2012"
So I thought that was only a format thing but when I do
Format(lastDateMill, "Long Date")
it equals “February-10-12”
This is how I update the date
DoCmd.RunSQL "UPDATE Mills SET LastContactDate = #" & SalesCallDate & "# WHERE MillID = " & lstMills.Column(0, i)
And the SalesCallDate = "2/10/2012" so the good date
So why the day and the month are switched?
The front end is ms-access-2010 and the back end is on SQL SERVER 2012
Your
SalesCallDatevariable contains a date as text:SalesCallDate = “2/10/2012”
Apparently you intend the date format of that string to be
m/d/yyyy, but it gets interpreted asd/m/yyyyformat.Store the string value in
yyyy/mm/ddformat to eliminate confusion due to locale issues …2012/02/10Since it turns out that
SalesCallDateis actually a text box containing a date value, change yourUPDATEapproach to avoid date problems due to locale.