在数据库中插入日期的问题 [英] Problem with inserting date in database

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

问题描述

您好,


我正在尝试在数据库中插入日期,但它不想以正确的格式输入。


我想插入日期01/02/2011(dd / mm / yyyy)。

我在页面上添加了一个response.write来检查代码是否正在处理它正确地,当我发送它时,它仍然是正确的日期。但是,当它被保存在数据库中时显示为30/12/1899,当您尝试在数据库本身手动更改它的值时,它显示0:00:21


我已经尝试了其他日期格式,例如2011/02/01(yyyy / mm / dd)或02/01/2011(mm / dd / yyyy)但没有任何成功。



就我的代码而言,日期是在url中传递的。

Hello,

I''m trying to insert a date into a database but it doesn''t want to go in in the right format.

I want to insert the date 01/02/2011 (dd/mm/yyyy).
I added a response.write to the page to check if the code is processing it properly and when I send it, it''s still the right date. However, when it''s being saved in the database it displays 30/12/1899 and when you try to change it''s value manually in the database itself it shows 0:00:21

I already tried alternative dateformats such as 2011/02/01 (yyyy/mm/dd) or 02/01/2011 (mm/dd/yyyy) but without any success.


As far as my code is concerned the date is being passed in the url.

展开 | 选择 | 换行 | 行号

推荐答案

它以字符串形式传递。可能,您需要做的是将字符串转换为日期或将其限定为将其插入数据库的日期。
It''s being passed as a string. Likely, what you''ll have to do is convert the string into a date or qualify it as a date when you insert it into the database.


我尝试了您的建议但没有成功:
I tried your suggestion but no success:
展开 | 选择 | Wrap | 行号


以明确的格式传递:2011年2月1日或2011年-feb-1。


Jared
Pass it in a nonambiguous format: February 1, 2011 or 2011-feb-1.

Jared


这篇关于在数据库中插入日期的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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