We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Date Confusion

jclothier
jclothier asked
on
Medium Priority
301 Views
Last Modified: 2010-04-24
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!
Comment
Watch Question

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

Author

Commented:
Hi Thanks for the reply. How would I code that?


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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks I'll try that and get back to you

Author

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!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.