DateDiff 函数
返回一个 Long 值,该值指定两个 Date 值之间的时间间隔数。
Dim DatTim1 As Date = #1/4/2001#   ' This is a Thursday.
Dim DatTim2 As Date = #1/9/2001#   ' This is the next Tuesday.
' Assume Sunday is specified as first day of the week.
Dim WD As Long = DateDiff(DateInterval.Weekday, DatTim1, DatTim2)
Dim WY As Long = DateDiff(DateInterval.WeekOfYear, DatTim1, DatTim2)

解决方案 »

  1.   

    3是整型怎么能减,把3转换成日期型Conver.ToDateTime(3);
    如if in_time > (now -Conver.ToDateTime(3))试试
      

  2.   

    错了应该是如if in_time > DateTime.Now.AddDays(-3)试试
      

  3.   

    错了应该是如if in_time > DateTime.Now.AddDays(-3)试试
      

  4.   

    datediff() SqlServer里也可以使用,再数据库端
      

  5.   

    select case when datefidd(dy,YourTimeColumn,GetDate()) <=3 then "new" else "old" end as IsNew from YourTable
      

  6.   

    错了:datediff(dy,YourTimeColumn,GetDate())
      

  7.   

    两个DataTime直接就可以比较!
      

  8.   

    谢谢各位,我试了一下 liuzhonghe(呆头鹅)的方法,解决饿了问题
    其余各位的方法应该也不错,最近忙不能一一试,见谅!