猴dai王也有悲伤时
人生若只如初见 何事秋风悲画扇
         /// <summary>
         /// 计算两个日期的时间间隔
         /// </summary>
         /// <param name="DateTime1">第一个日期和时间</param>
         /// <param name="DateTime2">第二个日期和时间</param>
         /// <returns></returns>
         private string DateDiff(DateTime DateTime1, DateTime DateTime2)
         {
             string dateDiff = null;
            
             TimeSpan ts1 = new TimeSpan(DateTime1.Ticks);
             TimeSpan ts2 = new TimeSpan(DateTime2.Ticks);
             TimeSpan ts = ts1.Subtract(ts2).Duration();
             dateDiff = ts.Days.ToString()+""
                 + ts.Hours.ToString()+"小时"
                 + ts.Minutes.ToString()+"分钟"
                 + ts.Seconds.ToString()+"";
            
             return dateDiff;
         }


//比较时间大小
string  st1="12:13";
string  st2="14:14";
DateTime  dt1=Convert.ToDateTime(st1);
DateTime  dt2=Convert.ToDateTime(st2);
DateTime  dt3=DateTime.Now;
if(DateTime.Compare(dt1,dt2)>0)
msg.Text=st1+">"+st2;
else
msg.Text=st1+"<"+st2;
 
--如果 
--RemindTime='' RemindFormata为空
--RemindTime大于现在,那么获取其时间差 。。天。。小时。。分钟
--RemindTime小于现在,那么截取获取其日期 例:08-31
select case when a.RemindTime='' then '' when a.RemindTime>GetDATE() then cast(floor(datediff(minute,GETDATE(),a.RemindTime) / 1440) as varchar)+''+cast(floor((datediff(minute,GETDATE(),a.RemindTime) % 1440)/60) as varchar)+'小时'+ cast(((datediff(minute,GETDATE(),a.RemindTime))-(floor(datediff(minute,GETDATE(),a.RemindTime) / 1440) *1440)-(floor((datediff(minute,GETDATE(),a.RemindTime) % 1440)/60)*60)) as varchar)+'' when a.RemindTime<GetDATE() then SUBSTRING(CONVERT(varchar(10), a.RemindTime, 23),6,10) end as RemindFormata from [dbo].[收文] as a order by ID DESC

 

posted on 2020-09-08 15:38  猴dai王也有悲伤时  阅读(287)  评论(0编辑  收藏  举报