我的应用程序中的DateTime错误? [英] DateTime error in my application?
问题描述
大家好我在Windows应用程序中遇到了这种类型的错误。
当我尝试在日期中插入或处理任何操作时...转向错误...
如何获得日期格式字符串:
以下方式处理日期:
1. MM / dd / yyyy
2 .dd / MM / yyyy。
如何避免这种类型的错误..基于系统日期格式..有些系统有MM / dd / yyyy和其他一些有dd / MM / yyyy如何处理所有这些应用程序的通用日期格式..
无法将参数值从String转换为DateTime。
以上是我的错误。
检查你的系统时间格式
例如:
我的系统时间格式是20 / Dec / 2013,这意味着dd / MMM / yyyy
DateTime dtime = DateTime.Parse(DateTime.Now.ToShortDateString());
string Sdtime = dtime.ToString( DD / MMM / YYYY跨度>);
并且在表格中插入日期时将字符串转换为日期时间格式
注意
表列字段必须有date数据类型
hi
试试这样。它可能对你有所帮助..
// MM / dd / yyyy
var valueFormat1 = DateTime.ParseExact( 12/30/2013, < span class =code-string> MM / dd / yyyy,CultureInfo.InvariantCulture);
// dd / MM / yyyy。
var valueFormat2 = DateTime.ParseExact( 30/12/2013 , dd / MM / yyyy,CultureInfo.InvariantCulture);
hi every one i got this type of error in Windows Application.
when i try to insert or handle any operation in Date ... its turn to error..
how to get a format string of Date:
following way to handle the date:
1. MM/dd/yyyy
2.dd/MM/yyyy.
how to avoid this type error..based on System Date Format.. some system has MM/dd/yyyy and some other have dd/MM/yyyy how to handle common date format for all this application..
Failed to convert parameter value from a String to a DateTime.
above is my error.
check your system time format
for example :
my system time format is 20/Dec/2013 that means dd/MMM/yyyy
DateTime dtime = DateTime.Parse(DateTime.Now.ToShortDateString()); string Sdtime = dtime.ToString("dd/MMM/yyyy");
and when insert date into table you convert the string to datetime format
Note
table column field must have "date" datatype
hi Try like this. It might help you..
// MM/dd/yyyy var valueFormat1 = DateTime.ParseExact("12/30/2013", "MM/dd/yyyy", CultureInfo.InvariantCulture); // dd/MM/yyyy. var valueFormat2 = DateTime.ParseExact("30/12/2013", "dd/MM/yyyy", CultureInfo.InvariantCulture);
这篇关于我的应用程序中的DateTime错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!