问题一:我想要的是一个datetime 类型的数据,它的值是当前系统时间之后的30天,请问如何获取?
问题二:如果datetime 类型的数据,为空值,请问如何处理?
public System.DateTime GD_TopBgnTime ;
TopBgnTime =DateTime.Now+30?TopBgnTime =null?大概类似的需求谢谢

解决方案 »

  1.   

    DateTime onemonthlater = DateTime.Now.AddMonths(1);
      

  2.   

                问题一:DateTime.Now.AddDays(30);
                问题二:1 Nullable<DateTime> a = null;
               2  DateTime? b = null;
      

  3.   

            DateTime.TryParse("19991-31-1", out onemonthlater);
            Console.WriteLine(onemonthlater.ToShortDateString());
      

  4.   

    DateTime d = DateTime.Now.AddDays(30);
            问题2 如果为空 那就不加呗。
      

  5.   

    Nullable<DateTime> a = null;
    string strDate=tt.value;");//前提要做格式判断,最好用日期控件 
    if(strDate.length>0)
    a=Convert.ToDateTime(strDate);//为字符串。如果是日期控件则不转型这样表单提交过来为空的时间。该a默认为空.