格式化传递到数据库的输入日期 [英] Format input date for passing to database

查看:57
本文介绍了格式化传递到数据库的输入日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我已经对此进行了几个小时的搜索,并且今晚花了很多时间阅读其他相关内容......但问题仍然不清楚。

我希望如果我提出我的具体问题,有人可以通过点击方式提供解决方案或解释。


我的网站由第三个人托管派对。我有一个表单请求用户的日期,然后将该日期存储在Access数据库中。我居住在北美,用户总是输入日期mm / dd / yyyy并且它一直存储在Access Db中,并且一直从Access Db中调用以便显示而没有问题。

直到上周。


我不确定我的主人是否改变了某些事情或发生了什么,但现在当我的用户在表格中输入日期时(mm / dd / yyyy)它被存储,随后在Access Db中显示为dd / mm / yyyy。


我正在使用非常简单的代码将信息传递给Db :


objrs.fields(" date")= request.form(" mydate1")

objrs.fields(" end_date")= request.form(" enddate")


表格代码如下所示:


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


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


从我今天所做的大量阅读看来,我的服务器现在正在存储发送给它的日期格式北美以外的格式。有没有办法让Db以接收它们的方式存储日期?

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("date") = request.form("mydate1")
objrs.fields("end_date") = request.form("enddate")

With the form code looking like this:

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

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


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?

推荐答案

看看下面的教程,看看它是否有帮助。 />

Literal DateTimes及其分隔符(#)。



如果没有回来,我们会尝试其他的东西。


Mary
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



查看以下教程,看看是否有帮助。


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



如果不回来我们会尝试其他的东西。


Mary
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



嗨玛丽,感谢您的回复。


您链接的教程可能会有所帮助,也可能没有帮助...但我对此非常陌生并且我很感动我不明白它试图教我什么。看起来它告诉我使用m / d / y作为我的字符串,并说你可以在将字符串传递给数据库之前格式化()一个字符串?


它不是''我很清楚,我没有看到任何例子。但是我的字符串mydate1和结束日期用户以2/7/2007格式(今天的日期)从我页面上的表格输入


我是否还需要格式化它们甚至如果他们以正确的格式输入?

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?



玛丽,谢谢你的回复。


你联系的教程可能会有所帮助,也可能没有帮助...但我对此很新,我真的不明白它教给我的是什么。看起来它告诉我使用m / d / y作为我的字符串,并说你可以在将字符串传递给数据库之前格式化()一个字符串?


它不是''我很清楚,我没有看到任何例子。但是我的字符串mydate1和结束日期用户以2/7/2007格式(今天的日期)从我页面上的表格输入


我是否还需要格式化它们甚至如果他们以正确的格式输入?
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?



访问处理以这种方式传递的日期时会遇到问题。问题不在于它们在网页上的格式如何,而是由Jet引擎如何解释Access接收的数据。


作为测试,将日期发送到测试字段有文字格式。这应该向您展示如何传递数据。如果文本显示正确的格式,那么您的问题在于Jet Engines对此的解释。如果实际上是这种情况,则在日期库中保存日期的字段中使用mm / dd / yyyy这样的格式,而不是使用此日期的访问默认格式。


让我知道你是怎么过的。


Mary

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


这篇关于格式化传递到数据库的输入日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆