Date Confusion

Hi All

I am having a problem with the MonthCalendar control. I have created a form which has the MonthCalendar control on it. the user then selects the required date and clicks the save button. The save button then writes this date into an Access Database field. All works fine if I pick say 25/10/2005 as a date, but when I select 02/03/2005 it saves the date as 03/02/2005 ?????

Here is a snippet of the code I use.

strSQL = "INSERT INTO MyTable (MyDate) VALUES (#" & MonthCalendar1.SelectionStart & "#)"

then I process the strSQL

Any help would be appreciated!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try to write the date in a non confusing format, e.g. yyyy/mm/dd or yyyy/mm/dd
I meant :yyyy/MM/dd or yyyy/MMM/dd

jclothierAuthor Commented:
Hi Thanks for the reply. How would I code that?
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.


strSQL = String.Format ("INSERT INTO MyTable (MyDate) VALUES (#" & MonthCalendar1.SelectionStart & "#)"

will be something like this:

   Dim strSQL As String = String.Format("INSERT INTO MyTable (MyDate) VALUES '{0}'", MonthCalendar1.SelectionStart.ToString("yyyy/MM/dd"))

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jclothierAuthor Commented:
Thanks I'll try that and get back to you
jclothierAuthor Commented:
Thanks That works. I made a slight change:

strsql = "INSERT INTO MyTable (MyDate) VALUES (#" & MonthCalendar1.SelectionStart.ToString("yyyy/MM/dd") & "#)"
ok, have fun coding!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.