The Problem:
When I insert dates in SQL Server 2000 into a field having a data type 'datetime', the date is recorded in US format even though I had specified a european format, e.g., 01/09/2002 gets recorded in the database as 09/01/2002.
The Code:
<cfset thedate = "01/09/2003">
<cfquery name="insertdate" datasource="main" dbtype="ODBC">
INSERT INTO testdate (expirydate)
VALUES ('#DateFormat(CreateODBCDate(thedate),"dd/mm/yyyy"#')
</cfquery>
SQL Server is configured to use UK settings and the computer's regional settings is set to the UK and the date format is set to dd/mm/yyyy.
I noticed that if I don't use #DateFormat(CreateODBCDate(thedate),"dd/mm/yyyy"# in the sql command and just put the date in directly, i.e.,
INSERT INTO testdate (expirydate)
VALUES ('01/09/2003') then the date gets recorded OK.
Why is this happening??
When I insert dates in SQL Server 2000 into a field having a data type 'datetime', the date is recorded in US format even though I had specified a european format, e.g., 01/09/2002 gets recorded in the database as 09/01/2002.
The Code:
<cfset thedate = "01/09/2003">
<cfquery name="insertdate" datasource="main" dbtype="ODBC">
INSERT INTO testdate (expirydate)
VALUES ('#DateFormat(CreateODBCDate(thedate),"dd/mm/yyyy"#')
</cfquery>
SQL Server is configured to use UK settings and the computer's regional settings is set to the UK and the date format is set to dd/mm/yyyy.
I noticed that if I don't use #DateFormat(CreateODBCDate(thedate),"dd/mm/yyyy"# in the sql command and just put the date in directly, i.e.,
INSERT INTO testdate (expirydate)
VALUES ('01/09/2003') then the date gets recorded OK.
Why is this happening??