Jasonchne
Jasonchne
采纳率73.7%
2019-06-20 15:58

Convert.ToDateTime()时间格式

已采纳

Convert.ToDateTime()时间后面怎么加上23:59:59.000

最近做一个查询,需要精确到时分秒,但是我去前台选定的时间:

DateTime jssj = Convert.ToDateTime(this.jssj.Value);

获取的结束时间是:2019-03-31 00:00:00.000

怎么把 2019-03-31 00:00:00.000 后面的 00:00:00.000 改成23:59:59.000
源代码如下:

DateTime kssj = Convert.ToDateTime(this.kssj.Value);
DateTime jssj = Convert.ToDateTime(this.jssj.Value);
DateTime kssjjy = kssj.AddDays(-1);
DateTime jssjjy = jssj.AddDays(1);
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • Jasonchne Jasonchne 2年前

    DateTime dtime = Convert.ToDateTime(this.jssj.Value);
    DateTime kssj = Convert.ToDateTime(this.kssj.Value);
    DateTime jssj = new DateTime(dtime.Year,dtime.Month,dtime.Day, 23,59,59);
    DateTime kssjjy = new DateTime(kssj.Year, kssj.Month, kssj.Day, 23, 59, 59).AddDays(-1);
    DateTime jssjjy = new DateTime(jssj.Year, jssj.Month, jssj.Day, 00, 00, 00).AddDays(1);
    string HName = this.mc.SelectedValue.ToString();

    点赞 评论 复制链接分享
  • weixin_43004500 小周瑜 2年前

    string time=jssj.ToShortDateString().ToString()+" 23:59:59.000";

    点赞 评论 复制链接分享