• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

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!
0
jclothier
Asked:
jclothier
  • 4
  • 3
1 Solution
 
PockyMasterCommented:
Try to write the date in a non confusing format, e.g. yyyy/mm/dd or yyyy/mm/dd
0
 
PockyMasterCommented:
I meant :yyyy/MM/dd or yyyy/MMM/dd

0
 
jclothierAuthor Commented:
Hi Thanks for the reply. How would I code that?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
PockyMasterCommented:


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"))

0
 
jclothierAuthor Commented:
Thanks I'll try that and get back to you
0
 
jclothierAuthor Commented:
Thanks That works. I made a slight change:

strsql = "INSERT INTO MyTable (MyDate) VALUES (#" & MonthCalendar1.SelectionStart.ToString("yyyy/MM/dd") & "#)"
0
 
PockyMasterCommented:
ok, have fun coding!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now