473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

What is the correct date format?

Hello Everyone!

I'm using VB6 with MS Access in back end. And the problem is when I add the records, the date format that I get from date picker is not entered into the table as intended. See example below for more clearity:

Dim strDate as String
strDate = "#" & DTPicker1.Day & "/" & DTPicker1.Month & "/" & DTPicker1.Year & "#". Also I even tried just DTPicker1.Value that too didn't work.

And in back end in table date field I'm using Short Date format like 16/6/2007.So When I entered 3rd Feb,2010(03/02/2010). It's just coming opposite that is 2nd Mar,2010(02/03/2010) in the table.

Therefore, Can any expert could help me & I would be grateful to you please...
Nov 25 '10 #1

✓ answered by Stewart Ross

Hi. Access date literals should really be entered in ANSI (American) date format (#m/d/y#), not UK format (#d/m/y#). Access will convert some UK date literals in #d/m/y# format correctly because there is only one way to interpret them - so #31/1/2010# will indeed represent 31 January. But, #3/2/2010# will be interpreted as 2 March as you have found.

You could simply change your date literal to #m/d/y# form as follows:

strDate = "#" & DTPicker1.Month & "/" & DTPicker1.Day & "/" & DTPicker1.Year & "#"

This does not change how the formatted date will be displayed at a later stage; it is just a means of entering the date correctly from your date picker.

You mention having tried the value returned by the date picker; if it is returning a true date value you should be able to enter that value directly into a variable of type date-time without using a date literal at all.

Anyhow, see how you get on with changing the date literal to #m/d/y# form.

-Stewart

1 1590
Stewart Ross
2,545 Expert Mod 2GB
Hi. Access date literals should really be entered in ANSI (American) date format (#m/d/y#), not UK format (#d/m/y#). Access will convert some UK date literals in #d/m/y# format correctly because there is only one way to interpret them - so #31/1/2010# will indeed represent 31 January. But, #3/2/2010# will be interpreted as 2 March as you have found.

You could simply change your date literal to #m/d/y# form as follows:

strDate = "#" & DTPicker1.Month & "/" & DTPicker1.Day & "/" & DTPicker1.Year & "#"

This does not change how the formatted date will be displayed at a later stage; it is just a means of entering the date correctly from your date picker.

You mention having tried the value returned by the date picker; if it is returning a true date value you should be able to enter that value directly into a variable of type date-time without using a date literal at all.

Anyhow, see how you get on with changing the date literal to #m/d/y# form.

-Stewart
Nov 29 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Himanshu Dora | last post by:
Hi I have set with lcid value. but i am not able to overcome my nt server regional setting. Actually i want a date in mm/dd/yyyy. But i get date as mm/dd/yy. How to ensure that i shall always get ...
4
by: Matteo | last post by:
Hy everybody. I'm not a html writer, but a sysadmin who's trying to help a user able to compile an online form with IE but not with Mozilla (Moz1.6, Ns7.1, Firefox 0.8+) due to a javascript date...
0
by: GMG | last post by:
Background : with XML data islands you can bind data to HTML tags. If you do not provide a DTD it will display the information as is. If you provide a DTD IE will display the data according to its...
4
by: Tony | last post by:
Hey guys, I use Google Groups quite a bit as it is an enormous wealth of information, and now I need some help. I have created a query using parameters to capture a range of date, the date is...
1
by: Rich | last post by:
Hello, I have some datefields in a dataset (ds1). I bind some textbox controls on a windows form to these date fields in ds1, but I only want to see 01/01/2004 instead of 1/1/2004 8:00:00 AM. ...
3
by: RJA | last post by:
Hiyas, Using VS .net 2003. Setting up a Webservice that accepts 3rd party vendor designed XML requests and returns a filled XMLDocument with response data. Vendor XSDs were serialize into...
3
by: Luqman | last post by:
I have deployed my ASP.Net Application on Windows Server 2000, Service Pack 4, when I run my Application and shows today's date with system.date.today.ToShortDateString, it shows in the format...
3
by: orajit | last post by:
Could you Please tell me how to handle incorrect date format exception in pl sql exception section.
1
by: Yas | last post by:
Hello I've got the following Javascript for a web calendar popup that outputs the date in 4/24/2008 (m/d/yyyy). How can i modify it to output dd/mm/yyyy e.g. 24/04/2008. So all outputs are in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.