473,672 Members | 2,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Format input date for passing to database

11 New Member
Hi there, I have done a few hours worth of searches on this and have spent the better part of tonight reading other threads about it... but yet the problem is still unclear to me.

I am hoping if I present my specific issue that someone can offer a solution or explanation in a way that clicks with me.

My site is being hosted by a third party. I have a form that requests a date from the user and then stores that date in an Access Database. I live in North America and the users always enter the date mm/dd/yyyy and it has always been stored in the Access Db that way and has always been recalled from the Access Db for display without issue.

Until last week.

I am not sure if my host changed something or what happened, but now when my users enter a date into the form (mm/dd/yyyy) it is being stored, and subsequently displayed, in the Access Db as dd/mm/yyyy instead.

I'm using very simple code to pass the info to the Db:

objrs.fields("d ate") = request.form("m ydate1")
objrs.fields("e nd_date") = request.form("e nddate")

With the form code looking like this:

<input type=text name="mydate1" size=12 value="<%= Date() %>" class="9pxTextC opy">

<input type=text name="enddate" size=12 class="9pxTextC opy">


From the extensive reading I have done today it looks like my Server is now storing the dates sent to it in a format other than standard North America. Is there a way to make the Db store the dates the way it is receiving them?
Feb 7 '07 #1
23 11252
MMcCarthy
14,534 Recognized Expert Moderator MVP
Have a look at the following tutorial and see if it helps.

Literal DateTimes and Their Delimiters (#).


If not come back and we'll try something else.

Mary
Feb 7 '07 #2
Holdstrong
11 New Member
Have a look at the following tutorial and see if it helps.

http://www.thescripts. com/forum/showthread.php? threadid=575420


If not come back and we'll try something else.

Mary
Hi Mary, thanks for the response.

The tutorial you linked may or may not help... but I am pretty new to this and I really didn't understand what it was trying to teach me. It looked like it was telling me to use m/d/y for my strings and saying that you can format() a string before passing it to the Database?

It wasn't clear to me and I didn't see any examples. But my strings "mydate1" and "enddate" from the form on my page are being entered by the user in a 2/7/2007 format (for today's date)

Do I still need to format them in someway even if they are being entered in the correct format?
Feb 7 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Mary, thanks for the response.

The tutorial you linked may or may not help... but I am pretty new to this and I really didn't understand what it was trying to teach me. It looked like it was telling me to use m/d/y for my strings and saying that you can format() a string before passing it to the Database?

It wasn't clear to me and I didn't see any examples. But my strings "mydate1" and "enddate" from the form on my page are being entered by the user in a 2/7/2007 format (for today's date)

Do I still need to format them in someway even if they are being entered in the correct format?
Access can have problems processing dates passed in this way. The problem is not how they are formatted on the web page but how the data received by Access is being interpreted by the Jet Engine.

As a test send the date to a test field that has a text format. This should show you how the data is being passed. If the text shows the correct format then your problem lies in the Jet Engines interpretation of that. If this is in fact the case then in the field that holds the date in the datebase use a format like mm/dd/yyyy rather than using the access default format for this date.

Let me know how you get on.

Mary
Feb 7 '07 #4
NeoPa
32,569 Recognized Expert Moderator MVP
A complicated issue to understand.
A couple of points that may make comprehension a little easier :
  1. Dates are not stored in any format other than decimal numbers.
  2. The Date part of a Date/Time field is integral
  3. The time part is a fraction of a day and is stored that way.
  4. The issue of dates appearing as strings of the wrong format is about how a date is formatted for viewing.
  5. A date string can appear as a date but is fundamentally different - one is a Date and the other a string.
  6. The tutorial is referring to problems handling dates within SQL code specifically. It is therefore unlikely to affect your issue directly (although it may well help you to appreciate the concepts involved).
To get to the route of your issue you need to understand exactly what is passed to where in the structure of your application. Finding out if it is the Access process which passes the date as an (incorrectly) formatted string to the next stage or whether it is the next stage itself which is misinterpreting it is a very important step. I would guess that one of the machines has been set up with British Regional settings, as we typically use the DD/MM/YYYY format over here.
Feb 7 '07 #5
Holdstrong
11 New Member
A complicated issue to understand. . .

To get to the route of your issue you need to understand exactly what is passed to where in the structure of your application. Finding out if it is the Access process which passes the date as an (incorrectly) formatted string to the next stage or whether it is the next stage itself which is misinterpreting it is a very important step. I would guess that one of the machines has been set up with British Regional settings, as we typically use the DD/MM/YYYY format over here.
Thanks for the follow ups. Great troubleshooting step by the way.

Ok so I created a test field in my Access Db and made sure it was set to text. I then altered my code slightly to pass the "mydate1" value from the user form to that text field instead of the usual Date/Time field and viola!

2/7/2007 is properly received and stored in that "testtext" field as the text 2/7/2007

Whereas "enddate", which is sent to the Date/Time field, gets received and stored as 7/2/2007

Ok, so I think we can say it is being passed along properly from the ASP page.

Here are the results when I send "mydate1" to "texttest" instead of "date" and when I send "enddate" to its original Date/Time field "end_date" via:

Expand|Select|Wrap|Line Numbers
  1. objrs.fields("textest") = request.form("mydate1")
  2.     objrs.fields("end_date") = request.form("enddate")
ID = 6035
name = testing
date =
end_date = 7/2/2007
textest = 2/7/2007
note = testing
employeeID = 13
Feb 7 '07 #6
NeoPa
32,569 Recognized Expert Moderator MVP
Unfortunately, you've only tested the difference between a date and a text field.
As both ends know that you're dealing with text neither would attempt to translate. As for the date, it was translated, but by which system.
I don't know the details of your setup, so I can only offer general advice.
  1. Check the Regional Settings on all relevant PCs.
  2. When doing any tests on date fields always use unambiguous date strings (EG 1 Jan 2007) for your test data.
Feb 7 '07 #7
Holdstrong
11 New Member
Unfortunately, you've only tested the difference between a date and a text field.
As both ends know that you're dealing with text neither would attempt to translate. As for the date, it was translated, but by which system.
I don't know the details of your setup, so I can only offer general advice.
  1. Check the Regional Settings on all relevant PCs.
  2. When doing any tests on date fields always use unambiguous date strings (EG 1 Jan 2007) for your test data.
Thanks again!

#1) The site is hosted by a third party company, so I suppose I can call them up and work through their tech support chain to try to get them to test out all of the machines relevant to our site. I have the feeling this might be a fruitless adventure but I will try

#2) If I send an unambiguous date string such as 7 Feb 2007 it is in fact translated correctly. So when I type in 7 Feb 2007 in both the "mydate1" and the "enddate" form field and send them to the same Access fields as mentioned before the new results are:

ID = 6036
name = testing
date =
end_date = 2/7/2007
textest = 2/7/2007
note = testing
employeeID = 13
Feb 7 '07 #8
Holdstrong
11 New Member
I may be getting ahead of myself here, but to recap:


Access is converting dates I send to it in the mm/dd/yyyy format and is storing them as dd/mm/yyyy.

However, if I send it an unambiguous date, such as 7-feb-2007 (dd/mmm/yyyy) or 2007/2/7 (yyyy/mm/dd) Access does receive and store the info correctly.

This appears to be a problem with a regional setting somewhere in my hosting solution. Since this is a third party hosting solution I have low hopes of them resolving it (but I am in contact with them)

It looks like another option would be to force people to insert the date in an unambiguous format... but, as we all know, relying on your users to do something, especially something which will feel foreign to them, is unlikely to produce happy results. However, what if there was a way for me to take the values entered in those forms and force a format change behind the scenes BEFORE it gets passed to Access?

In other words, my user enters 2/7/2007 in my form. That value is saved as "mydate1" via simple form HTML:

Expand|Select|Wrap|Line Numbers
  1. <input type=text name="mydate1" size=12 class="9pxTextCopy">
and then is passed along to he database as is via:

Expand|Select|Wrap|Line Numbers
  1. objrs.fields("mydate1") = request.form("mydate1")
But what if before passing along to the database I converted "mydate1" somehow... maybe using FormatDateTime( )??

Here is where my extreme noobness will shine. I have no idea how I would take a value from a Form ("mydate1") and run it through something like FormateDateTime before sending it off to the Db.
Feb 7 '07 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
I may be getting ahead of myself here, but to recap:


Access is converting dates I send to it in the mm/dd/yyyy format and is storing them as dd/mm/yyyy.

However, if I send it an unambiguous date, such as 7-feb-2007 (dd/mmm/yyyy) or 2007/2/7 (yyyy/mm/dd) Access does receive and store the info correctly.

This appears to be a problem with a regional setting somewhere in my hosting solution. Since this is a third party hosting solution I have low hopes of them resolving it (but I am in contact with them)

It looks like another option would be to force people to insert the date in an unambiguous format... but, as we all know, relying on your users to do something, especially something which will feel foreign to them, is unlikely to produce happy results. However, what if there was a way for me to take the values entered in those forms and force a format change behind the scenes BEFORE it gets passed to Access?

In other words, my user enters 2/7/2007 in my form. That value is saved as "mydate1" via simple form HTML:

Expand|Select|Wrap|Line Numbers
  1. <input type=text name="mydate1" size=12 class="9pxTextCopy">
and then is passed along to he database as is via:

Expand|Select|Wrap|Line Numbers
  1. objrs.fields("mydate1") = request.form("mydate1")
But what if before passing along to the database I converted "mydate1" somehow... maybe using FormatDateTime( )??

Here is where my extreme noobness will shine. I have no idea how I would take a value from a Form ("mydate1") and run it through something like FormateDateTime before sending it off to the Db.
I'll post a pointer question in HTMS/CSS and see if anyone can help.

Mary
Feb 7 '07 #10

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

Similar topics

10
8037
by: Bob Bedford | last post by:
I've two input fields in wich the user enter dates. I've put something like "enter date here (dd/mm/yyyy) but most of the user don't enter date in correct format. So I'd like to be able to get any format coming from user as I must put those dates in a MySQL database: some format: (non-US format, so day/month/year) 1/9/2004 1/09/2004 01/9/2004
3
2873
by: Stefan van Roosmalen | last post by:
Hi there, I have developed several applications in Delphi. I used Paradox for my data storage. Now, I want to convert these databases to MySql. So that why I am looking for a way to convert the date format from YYYY-MM-DD to MM/DD/YYYY. Is this possible??? gr.,
7
3162
by: Niall Porter | last post by:
Hi all, I'm building an ASP app on a Windows 2000/IIS machine which interfaces with our SQL Server 2000 database via OLE DB. Since we're based in the UK I want the users to be able to type in dates in UK date format to input into the database. In Enterprise Manager on the SQL Server I can manually enter a record into a table and just type in a UK date (MM/DD/YYYY e.g. 25/12/2004) and it accepts it happily.
5
10704
by: Tim Marsden | last post by:
Hello, I am building a parameterised query in vb.net for execution against a SQL server database. I am using a OLEDB command and OLEDB parameters. If one of the parameters is a date I sometimes experience a problem in the interpretation of the format. I populate the parameter value from a user input text box. I am in the UK so the use inputs in the format dd/mm/yy. I know SQL user the US format of mm/dd/yy.
5
8390
by: Ben Williams | last post by:
Hello, I'm hoping i'm posting to the correct newsgroup - this question involves both a SQL database and VB. I am a newbie and i'm writing a program in which one of a handful of fields will have a date entered. The contents of this field (and others) need to be written back to a SQL database. The 'date' field will be input in the format of the Regional settings (mainly dd/mm/yyy for the UK). When it comes to the point where it is...
13
3293
by: Roy | last post by:
Hi all, I'm creating a project that should always use this date format when displays the dates or create dates. The back end database is a SQL Server and I like to know what is the logical way to configure server, sql server or program so it always deals with date as mm/dd/yyyy format. Thanks in advance. Roy
7
4276
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 is configured to use Reginol settings date
2
11508
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: CAST(O.MYDATE AS CHAR(30)) When directly updating date fields in the main table, the logged value gets saved in the format YYYY-MM-DD as expected.
6
3971
by: ruraldev | last post by:
I have been trying my best to display a chosen date as dd-mm-yyyy but insert it into the mysql database as yyyy-mm-dd, I know it must be simple but no matter what I try I can't get it to work. At the moment the date is displayed as dd-MM-yyyy but of course this won't add to the mysql database, if I change the display to yyyy-MM-dd then it displays in that format (which I don't want) but will add to the database OK. I had thought that I...
0
8486
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8404
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8931
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8828
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6238
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5705
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
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
2
1816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.