string 转换成 DateTime

yxiaoxiong 2005-03-17 03:46:02
strDT = "08/16/02"
DateTimeFormatInfo dtFI = new DateTimeFormatInfo();
dtFI.ShortDatePattern = "MM/dd/yy";
DateTime.Parse(strDT,dtFI)

error: arguments do not match parameters for function 'DateTime.Parse'
...全文
1552 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
beibeilong 2005-03-17
  • 打赏
  • 举报
回复
插入数据库的时候字符串个是不正确
yxiaoxiong 2005-03-17
  • 打赏
  • 举报
回复
没有人知道?
yxiaoxiong 2005-03-17
  • 打赏
  • 举报
回复
其实代码本身没错,奇怪的是在command window 下运行才会出错。
另外问一下,datetime在插入数据库是为什么会出现Syntax error converting datetime from character string
CSDNATM 2005-03-17
  • 打赏
  • 举报
回复
三个星星,我什么时候才能得到三个星星呀?
leiaming 2005-03-17
  • 打赏
  • 举报
回复
呵呵,强大
xixigongzhu 2005-03-17
  • 打赏
  • 举报
回复
上面的写错了点,应该是:
strDT = "08/16/02";
DateTime.ParseExact(strDT,"MM/dd/yy",null);
xixigongzhu 2005-03-17
  • 打赏
  • 举报
回复
strDT = "08/16/02";
DateTime.Parse(strDT,"MM/dd/yy",null);
孟子E章 2005-03-17
  • 打赏
  • 举报
回复
using System;
using System.Windows.Forms;
using System.Globalization;
public class Test1
{
static void Main()
{
string strDT = "08/16/02";
DateTimeFormatInfo dtFI = new DateTimeFormatInfo();
dtFI.ShortDatePattern = "MM/dd/yy";
DateTime aa = DateTime.Parse(strDT,dtFI);
Console.Write(aa.ToString("yyyy-MM-dd"));
}
}
DeltaCat 2005-03-17
  • 打赏
  • 举报
回复
string strDT = "08/16/02";
DeltaCat 2005-03-17
  • 打赏
  • 举报
回复
strDT = "08/16/02";
DateTimeFormatInfo dtFI = new DateTimeFormatInfo();
dtFI.ShortDatePattern = "MM/dd/yy";
DateTime dt = DateTime.Parse(strDT,dtFI);

110,537

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧