换算设备使用年限

2016-02-22 10:16:55  访问(1512) 赞(0) 踩(0)


    /// <summary>
    /// 换算设备使用年限
    /// </summary>
    /// <param name="theValue"></param>
    /// <returns></returns>
    protected string DateTimeNullToUsed(DateTime? theValue)
    {
        if (theValue == null)
            return "";

        int nowYear = DateTime.Now.Year;
        int nowMonth = DateTime.Now.Month;
        int uYear =  theValue.Value.Year;
        int uMonth = theValue.Value.Month;
 
        int subY = nowYear - uYear;

        if (subY == 0)
            return "";

        int subM = nowMonth - uMonth;

        if (subM < 0)
            subY -= 1;

        if (subY == 0)
            return "";

        return subY.ToString() + "年";
    }


标签:换算设备使用年限 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)