日期问题 - ASP / SQL [英] Date Problems - ASP/SQL

查看:73
本文介绍了日期问题 - ASP / SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我在SQL服务器中有一个日期字段 - 日期为DD / MM / YYYY格式

(GB)。


现在,我有一个ASP应用程序,在此表中添加/编辑记录;并且我在这个应用程序的ADD和编辑(更新)

部分的日期字段中遇到了实际问题。


基本上,我接收和错误如下:


****

错误类型:

Microsoft OLE DB Provider for ODBC驱动程序(0x80040E07)

[Microsoft] [ODBC SQL Server驱动程序] [SQL Server]将char数据

类型转换为日期时间数据类型导致输出范围的日期时间值。

/add.asp,第105行

****


这发生在我的时候尝试以DD / MM / YYYY格式输入日期,通过

ASP表格。当我尝试MM / DD / YYYY时效果很好,我需要它作为GB不是

美国!


任何想法如何解决这个问题?

我已经在ADD / Edit页面的顶部输入了这个:


<%session.LCID = 2057%> (只是在黑暗中刺伤)


任何想法非常感谢


-

提前致谢


Fawke


请在给我发电子邮件之前从我的电子邮件地址中删除ANTI和SPAM



www.bradflack.com

Hi there,

I have a date field in SQL server - that holds dates as DD/MM/YYYY format
(GB).

Now, i have an ASP application that Adds/Edits records in this table; and i
am having real problems with the date field in the ADD and EDIT (update)
part for this app.

Basically, i receive and Error as below:

****
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of a char data
type to a datetime data type resulted in an out-of-range datetime value.
/add.asp, line 105
****

This occurs when i try to input a date in the format of DD/MM/YYYY through
an ASP Form. When i try it as MM/DD/YYYY it works great, I need it as GB not
US!

Any ideas how i can fix this?
I have already entered this at the top of the ADD/Edit page:

<%session.LCID=2057%> (just a stab in the dark)

Any ideas much appreciated

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com

推荐答案

将日期设为YYYY / MM / DD。


这是我在传递dd / mm / yyyy日期时使用的功能,效果很好。

使用类似这样的更新tblMisc set mydatefield = convDate(''dd / mm / yyyy'')


<%

''此函数从文本字符串中接收日期格式为dd / mm / yy或

dd / mm / ccyy

''并创建一个兼容的字符串插入sql作为

日期时间字段

''如果传递空字符串,它只会传回修剪后的原始

''写入值测试sql数据库的值e''datetime''字段

''已添加16/04/2003

''如果通过了2位数年份,那么20年将被添加到年份以构建

CCYY年

''---------

''sValues =" NULLIF(''"& convdate(sDate)&"'','''')"

''---------

''传递日期为dd / mm / yy

函数convDate(theDate)

Dim Itemp

如果TRIM(theDate) <> ""然后

sTemp = cdate(theDate)

dteArray =拆分(sTemp," / - , - 1,1)

如果LenB (dteArray(2))= 2然后

dteArray(2)=" 20" &安培; dteArray(2)

结束如果

convDate = dteArray(2)& " /" &安培; dteArray(1)& " /" &安培; dteArray(0)

Else

convDate =修剪(theDate)

结束如果

结束功能
%>


" Fawke101" < gu*@ANTIbradflack.SPAMcom>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP11.phx.gbl ...
Put the date in as YYYY/MM/DD .

This is a function i use when passing in dd/mm/yyyy dates and works well.
Use like this update tblMisc set mydatefield = convDate(''dd/mm/yyyy'')

<%
''This function recieves a date from text string in format dd/mm/yy or
dd/mm/ccyy
''And creates a string that is compatible with inserting into sql as a
datetime field
''If an empty string is passed it just passes back trimmed original
''Write Value Test value to sql database ''datetime'' field
''Added 16/04/2003
''If a 2 digit year is passed then 20 is prepended onto year to build a
CCYY year
''---------
''sValues = " NULLIF(''" & convdate(sDate) & "'','''')"
''---------
''pass a date as dd/mm/yy
Function convDate(theDate)
Dim Itemp
If TRIM(theDate) <> "" Then
sTemp = cdate(theDate)
dteArray = Split(sTemp,"/",-1,1)
If LenB(dteArray(2)) = 2 Then
dteArray(2) = "20" & dteArray(2)
End If
convDate =dteArray(2) & "/" & dteArray(1) & "/" & dteArray(0)
Else
convDate = Trim(theDate)
End If
End Function
%>

"Fawke101" <gu*@ANTIbradflack.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
你好,

我在SQL服务器上有一个日期字段 - 日期为DD / MM / YYYY格式
(GB)。

现在,我有一个ASP在此表中添加/编辑记录的应用程序;和
i我在这个应用程序的ADD和编辑(更新)部分中的日期字段存在实际问题。

基本上,我收到和错误如下:

****
错误类型:
用于ODBC驱动程序的Microsoft OLE DB提供程序(0x80040E07)
[Microsoft] [ODBC SQL Server驱动程序] [SQL Server]转换为日期时间数据类型的char
数据类型导致日期时间值超出范围。
/ add.asp,第105行
****
当我尝试通过ASP表单输入DD / MM / YYYY格式的日期时会发生这种情况。当我尝试MM / DD / YYYY时效果很好,我需要它作为GB
不是美国!

任何想法如何解决这个问题?
我已经进入这在ADD / Edit页面的顶部:

<%session.LCID = 2057%> (只是在黑暗中刺伤)

任何想法都非常感激

-
提前致谢

Fawke

请在给我发电子邮件之前从我的电子邮件地址中删除ANTI和SPAM


www.bradflack.com
Hi there,

I have a date field in SQL server - that holds dates as DD/MM/YYYY format
(GB).

Now, i have an ASP application that Adds/Edits records in this table; and i am having real problems with the date field in the ADD and EDIT (update)
part for this app.

Basically, i receive and Error as below:

****
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value.
/add.asp, line 105
****

This occurs when i try to input a date in the format of DD/MM/YYYY through
an ASP Form. When i try it as MM/DD/YYYY it works great, I need it as GB not US!

Any ideas how i can fix this?
I have already entered this at the top of the ADD/Edit page:

<%session.LCID=2057%> (just a stab in the dark)

Any ideas much appreciated

--
Thanks in advance

Fawke

Please remove ANTI and SPAM
from my email address before emailing me.

www.bradflack.com



Pucker ....这很棒,为此欢呼......工作待遇


只需一件事 - 为什么这会被注释掉? -
Pucker.... thats great, cheers for that... works a treat

Just one thing - how come this is commented out? -
''---------
''sValues =" NULLIF(''"& convdate(sDate)&"'','''')"
''---------
''---------
''sValues = " NULLIF(''" & convdate(sDate) & "'','''')"
''---------




这部分究竟做了什么?

-

提前谢谢


Fawke


请在给我发电子邮件之前从我的电子邮件地址中删除ANTI和SPAM



www.bradflack.com


为什么要解决这类问题?已经在这篇文章中发表了1891次。

请查看 www.aspfaq.com
Why stiil ansering this kind of questions ? Already in this post 1891 times.
Please check www.aspfaq.com


这篇关于日期问题 - ASP / SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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