Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
when i am inserting date using vb in my access database showing wrong date

if my date is 01/04/2013 i.e. 1st April 2013 and when i am saving in database Access 2003 it shows me 04/01/2013 i.e. 04th Jan 2013 but this problem in XP only when i tried at my friend house it save perfect i.e. 1st April 2013 he uses windows 7.



Help me out of this


Frontend VB.net 2005 and backend Access 2003

in access datecolumn data type is date/time with short date formate
my code is
VB
"Insert into tablename(dateColumn) values('" & dtp.value & "')"  ' dtp.value= 01/04/2013
Posted
Updated 3-Apr-13 23:18pm
v3

It is nothing to do with Access.
It is to do with the Culture settings on the PC. Look at the Control Panel, under (I think - it's been a while) International Settings and you will find that the PC using 4th Jan 2013 is set to US or similar MM/dd/yyyy, where the other is set to European dd/MM/yyyy
 
Share this answer
 
Comments
Maciej Los 4-Apr-13 4:20am    
Yes, it does. Please, see my answer and read related links.
Sounds like you just have a culture problem with the stored dates. The american way would write 1st April 04/01/2013 while most of the europeen writes 1/4/2013. But since I assume that you stored the value DateTime type in the database it shouldnt be a problem.
 
Share this answer
 
Comments
Maciej Los 4-Apr-13 4:21am    
Yes, regional setting (culture) is a problem. See my answer and related links. DateTime data type field does not resolves problem ;(
hareshdgr8 4-Apr-13 4:33am    
if i set datetime datatype in dateValue it also give me same problem in access database.
Thats No Issue
It is to do with the Culture settings on the PC. Look at the Control Panel,Regional Setting And Then Click On Date Option And Change The Date Format which is improper till Now

You Have to Change Short Date Format according to your Requirement dd/MM/yyyy
 
Share this answer
 
v2
Comments
Maciej Los 4-Apr-13 4:23am    
Changing regional settings does not guaratee 100% success.
hareshdgr8 4-Apr-13 4:40am    
yes you are right then what i have to do sir.
hareshdgr8 4-Apr-13 5:11am    
i did it but not solved what i did i am writing code for that whenever my application starts it change data format at dd/MM/yyyy after that same problem occur please tell me what should i do now
MS Access uses date format from system regional settings: short date format. To properly save date into MS Access database, you should set CultureInfo[^]. Than use DateTimeFormatInfo.FullDateTimePattern[^] to set date-string in correct format.

Tip:
The easiest way to avoid replacement between day<->month, is to use "en-US" date format ;)

More:
Globalization Namespace[^]
DateTimeFormatInfo[^]
10 tips for working with dates in MS Access[^]
MS Access tips: International Dates in Access[^]
 
Share this answer
 
v2
Comments
hareshdgr8 4-Apr-13 4:57am    
my question is not solved please give me hint to what should i do.
Maciej Los 4-Apr-13 5:07am    
Please, post a code for insert data. Use "Improve question" widget (rigth-bottom corner of question section).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900