[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

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