5 pts.
 Date insert problem into Access from .NET
I have a procedure that inserts a record including a date into an Access database. If the dd portion of the date can equate to a month then the dd and mm parts of the date are switched otherwise the date remains as is. eg 12/11/2007 is being stored as 11/12/2007 but 13/12/2007 is stored as 13/12/2007. I can code round this but surely the rules should be consistent. The insert statement is INSERT INTO ACCTRANSFER VALUES (" & MaxHeaderID & ", " & intAccFromCode & ", " & intAccToCode & ", " & Val(Me.txtAmount.Text) & ", #" & CDate(Me.txtTransferDate.Text) & "#)". Can anyone throw any light on this please.

Software/Hardware used:
ASKED: January 20, 2009  4:54 PM
UPDATED: January 21, 2009  8:25 PM

Answer Wiki:
Use the "mm-dd-yy" format in SQL. If you store the date in the "dd-mm-yy" format in your database, you can use the following: INSERT INTO ACCTRANSFER VALUES (" & MaxHeaderID & ", " & intAccFromCode & ", " & intAccToCode & ", " & Val(Me.txtAmount.Text) & ", #" & format(Me.txtTransferDate.Text, "mm-dd-yy") & "#)". > 13/12/2007 is stored as 13/12/2007 In this case the correct treatment is due to the fact that a month can't be more than 12. :-)
Last Wiki Answer Submitted:  January 21, 2009  8:25 pm  by  msi77   1,610 pts.
All Answer Wiki Contributors:  msi77   1,610 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _