473,569 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Format when inserted in Database

132 New Member
Hello,

I have a problem when I try to insert dates in my database.

I want to insert a date range in my table in the dd/mm/yyyy format.

When I insert for instance 01/05/2011 (1st of May) it shows in my db as 5/01/2011

However when I get to 13/05/2011 it is showing ok.

The result that I get is:

05/01/2011
05/02/2011
05/03/2011
05/04/2011
05/05/2011
05/06/2011
05/07/2011
05/08/2011
05/09/2011
05/10/2011
05/11/2011
05/12/2011
13/05/2011
14/05/2011
15/05/2011
16/05/2011
17/05/2011
18/05/2011
19/05/2011
20/05/2011

So starting at 13/05 that's the right format. Before it's the wrong format.
It has to be something with the date format but I don't know what.

Below is the code I use to add the dates:
Expand|Select|Wrap|Line Numbers
  1. <%@ LANGUAGE="VBSCRIPT"%>
  2.  
  3. <% 
  4.  
  5. dim StartDate
  6. dim StopDate
  7. dim CurrentDate
  8. dim SQL
  9.  
  10. StartDate = cdate(request.querystring("From"))
  11. StopDate = cdate(request.querystring("To"))
  12.  
  13.  
  14. response.write("Please wait while we create your page.<br>")
  15.  
  16.  
  17. Set OBJdbconnection = Server.CreateObject("ADODB.Connection")
  18.  
  19. OBJdbConnection.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../data/Meetup.mdb")
  20.  
  21. CurrentDate = cdate(StartDate)
  22. currentdate.formatdate()
  23. Do while CurrentDate <= StopDate
  24.   SQL = "INSERT INTO Meeting (Date) VALUES (#" & CurrentDate & "#)"
  25.   OBJdbConnection.Execute(SQL) 
  26.   response.write(CurrentDate & "<br>")
  27.  
  28.   CurrentDate = DateAdd("d",1,CurrentDate)
  29.  
  30. loop
  31.  
  32. OBJdbConnection.Close 
  33. set SQL = nothing 
  34.  
  35. Response.write("Your page has been created.")
  36. 'Response.redirect("db.asp")
  37. %> 
  38.  
  39.  
Anybody that can help me with this?

Thanks,
Kenneth
May 9 '11 #1
1 4026
jhardman
3,406 Recognized Expert Specialist
Kenneth,

The problem is the regionalization settings for your database. All Microsoft products by default use American regionalization , and you are using MS Access as your database. In the US we do not say "1st May" we say "May 1st", so the default format in the US is mm/dd/yyyy. Up to day twelve you have ambiguous dates; 3/5/2011 and 5/3/2011 could mean the same thing depending on who writes it. The database is guessing which one you mean based on US regionalization .

The best solution to your problem is to use a non-ambiguous date format such as "3-May-2011" or "2011 May 03" or "May 03, 2011" any of which will be interpreted correctly by the database.

Alternatively you could change the regionalization of your database, I'm sure it is possible, but I have never done it in access. But really, the other solution is better from a standards point of view: 3/5/2011 means different things to different people but 3-May-2011 can only mean one thing.

Jared
May 9 '11 #2

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

Similar topics

6
2332
by: Greg | last post by:
Isn't the following date format supposed to work with any installation of MySQL? YYYY-MM-DD HH:NN:SS It's not working on one system... the date is shown as all zero's.
0
1386
by: John Smith | last post by:
I'm passing two date parameters into a crystal report but it won't let me input anythign other than mm/dd/yy. What I want to put in is dd/mm/yy. Here is my code: Dim cr As New cleaningHistory Dim objParameterFieldDefinition As CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinition
1
4834
by: Laurence Neville | last post by:
This is regarding a change in the Short Date format under Hebrew Regional Settings, that has caused huge problems in our ASP web application. The change appears to have been introduced sometime before Windows 2000 Service Pack 4 and has remained through to Windows XP. I am looking for a solution that doesn't involve rewriting our application...
5
1901
by: jeff | last post by:
i have written a program with date format as m/d/yyyy when i deploy it to client's machine, due to the client use d/m/yyyy format the Select SQL statement return some record wrongly. how can i fix this problem ? set the user's locale / date format when program launch and reset it during exit ? Pls let me know your way to solve it. many...
7
4271
by: mewanalwis | last post by:
Dear Friends, I have a rather strange problem which invloves SQL server and ASP. The problem is this. I have an ASP application which use a SQL server. it saves date values with MM/dd/yyyy format. the SQL server and every other computer is configured to MM/dd/yyyy format in reginol settings. The DSN which use to connect to SQL server...
2
2253
by: jpr | last post by:
Friend, I am using a code to export data from a table to a word document using bookmarks and have a problem with a date format. When I export a field that is a mm/dd, in my word doc it shows up with the format mm/dd/yyyy. Is there a way I can export to show the format mm/yyyy? This is the code: ...
1
24547
by: somaskarthic | last post by:
Hi In postgresql database how to retrieve the date in a required format ? Is ther any method to retrieve the stored date value in mm/dd/yyyy format. I don't want to set the date format in postgres databse . Whatever format the date value stored , is there any method to retrieve the date in any required format ? Pls post your replies Thank...
2
2205
by: mrteno | last post by:
I'm using mysql, and used field with DATE type the default date format in my database is yyyy/mm/dd how to change the date format to dd/mm/yyyy
10
5796
by: ARC | last post by:
Hello all, General question for back-end database that has numerous date fields where the database will be used in regions that put the month first, and regions that do not. Should I save a date format in the table design, such as: mm/dd/yyyy? What I've done for years is to store the date format in date fields, then on the forms, based...
7
7689
by: Vishnu R | last post by:
Dear All, I am trying to format the data to DMY in the excel file which is exported to excel using the transfer spreadsheet command. I am trying to format using text to columns as udner. .Range("AA2", xlapp.Range("AA65536").End(xlUp)).Select .Selection.TextToColumns Destination:=xlapp.Range("AA2"), DataType:=xlDelimited, _ ...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5222
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.