Asp.net 如何将en gb转换为en us(将表达式转换为数据类型datetime时出现算术溢出错误)
将表达式转换为数据类型datetime时出现算术溢出错误。声明已终止。 我的网站的文化是en gb(18/10/2010) 我的db服务器的文化是en-us(10/18/2010) 日期存储在参数中Asp.net 如何将en gb转换为en us(将表达式转换为数据类型datetime时出现算术溢出错误),asp.net,datetime,localization,culture,Asp.net,Datetime,Localization,Culture,将表达式转换为数据类型datetime时出现算术溢出错误。声明已终止。 我的网站的文化是en gb(18/10/2010) 我的db服务器的文化是en-us(10/18/2010) 日期存储在参数中 command.Parameters.AddWithValue("@bookingdate", inputBookingDate.Text) 在进入数据库之前,是否有办法将其转换为美国日期格式 我试过这个密码 Dim dbDate As String = command.Parameter
command.Parameters.AddWithValue("@bookingdate", inputBookingDate.Text)
在进入数据库之前,是否有办法将其转换为美国日期格式
我试过这个密码
Dim dbDate As String = command.Parameters("@bookingdate").Value.ToString
dbdate = DateTime.Parse(dbdate, New CultureInfo("en-US"))
command.Parameters("@bookingdate").Value = dbdate
但是获取错误“字符串未被识别为有效的日期时间”。
dbDate = "29/10/2010 00:00:00"
如何指定当前区域性?将dbDate标识为GB格式的有效日期时间
谢谢。试试看。以GB格式读入日期,以US格式写出日期。这也是检查UI代码的好时机,以确保它在任何地方都使用GB格式。或者更改数据库所需的格式
如果数据库支持,您可以将日期写为时间戳,以尽量减少使用美国日期格式的次数。试试看。以GB格式读入日期,以US格式写出日期。这也是检查UI代码的好时机,以确保它在任何地方都使用GB格式。或者更改数据库所需的格式
如果数据库支持,您可以将日期写为时间戳,以尽量减少使用美国日期格式的次数