C# 计算时间间隔

 var dt = DateTime.Now;
            TimeSpan ts1 = new TimeSpan(dt.Ticks);
            TimeSpan ts2 = new TimeSpan(dt.AddDays(-1).Ticks);
            TimeSpan ts = ts1.Subtract(ts2).Duration();
            Console.WriteLine(ts.TotalSeconds);


当月第一天0时0分0秒:


DateTime.Now.AddDays(1 - DateTime.Now.Day).Date


当月最后一天23时59分59秒:


DateTime.Now.AddDays(1 - DateTime.Now.Day).Date.AddMonths(1).AddSeconds(-1)

--最大支付时间

select * from CMCustomer A inner join
(select MAX(AddTime) as addtime,CustomerID from CMChargeGoodsOrderDetail where Status=2 group by CustomerID) tab on tab.CustomerID=A.uid
where 1=1

 

 

posted @ 2021-02-02 11:06  天才卧龙  阅读(259)  评论(0编辑  收藏  举报