DateTime d1,d2;
TimeSpan = d2-d1;
Result=format(d2-TimeSpan,"YY年MM月DD日")

解决方案 »

  1.   

    DateTime d1,d2;
    TimeSpan ts=new TimeSpan(d2.Ticks-d1.Ticks);ts.ToString("yyyy年MM月");
      

  2.   

    System.DateTime dt1=DateTime.Parse("2000-3-2".ToString());
    System.DateTime dt2=DateTime.Parse("2003-1-2".ToString());
    int Year1=int.Parse(dt2.Year.ToString())-int.Parse(dt1.Year.ToString());
    int Month1=int.Parse(dt2.Month.ToString())-int.Parse(dt1.Month.ToString());
    if(Month1<0)
     {
       Year1=Year1-1;
       Month1=12+Month1;
     }
    String strSpan=Year1.ToString()+"年"+Month1.ToString()+"月";//strSpan就是你要的数值,当然也可以继续计算出年月日,同理
      

  3.   

    triout(笨牛) 提示重载“ToString”方法未获取“1”参数
      

  4.   

    ts.ToString("yyyy年MM月");?????????????????
    DateTime d1,d2;
    d1=DateTime.Now;
    d2=this.dateTimePicker1.Value;  
    TimeSpan ts= d2-d1;
    DateTime d3=new DateTime(ts.Ticks);
    MessageBox.Show(string.Format("{0:yyyy年MM月 }", d3));
      

  5.   

    如计算现在到2000-6-1得出的工龄
    CMIC(大象) 的方法得出  04年08个月 
    rferen2003(流水)的方法得出  3年零7个月
    正确的为rferen2003(流水)的方法