Date insert problem into Access from .NET

5 pts.
Tags:
Microsoft Access
VB.NET
VB.NET 2003
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.
ASKED: January 20, 2009  4:54 PM
UPDATED: January 21, 2009  8:25 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

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. :-)

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following