欢迎大家访问我的BLOG,我会多多的出原创文章,希望大家支持我,为我祈祷,让我实现我的三个梦想!再30岁能成为一个名优秀的软件架构师!

用c#怎么使用datediff()方法

用c#怎么使用datediff()方法,这个方法直接写好像找不找

 作 者:纭纭~(curry6666)
 时 间:2006-4-27 11:46:28
这个方法是返回两个日期之间的相差的天数的

回复人:netpot(netpot)2006-4-27 11:54:49
DateTime dt1,dt2;
TimeSpan ts = dt1 - dt2;
int i = Convert.ToInt(ts.TotalDays);
回复人:车房志之扯坏的领带(zhuxiaojun2002)2006-4-27 11:56:33
datediff是sql中的函数吧
用timespan
代码如下:
using System;
using System.Collections;
public class DatediffClass
{
public static void Main()
{
DateTime dt1 = DateTime.Parse("2006-04-01");
DateTime dt2 = DateTime.Parse("2006-05-01");
TimeSpan ts = dt2.Subtract(dt1);
Console.WriteLine(ts.TotalDays);
Console.ReadLine();
}
}
回复人:jijl2001(jijl2001)2006-4-27 11:57:24
楼上正解 用TimeSpan

posted on 2006-07-12 15:43  程序缘  阅读(3222)  评论(0)    收藏  举报

导航