zoukankan      html  css  js  c++  java
  • 2个日期做比较 小于3天

    今天做开发一个需求,最近3天的新闻后面加一个NEW图标 ,经过研究完成.  代码如下:

     DateTime dttt = DateTime.Now;
                       
                        //string dttt12 = dttt.ToString("yyyy-MM-dd");

                       

                        if ((DateDiff(Convert.ToDateTime(timeFormat.ToString()), dttt).Days) <= 3)

                            style1 = style1.Replace("$newimg", "<img src=images/gif-0246.gif />");
                        else
                            style1 = style1.Replace("$newimg", "");

    里面的日期格式转换 费了些时间     不过在SQL里函数DateDiff非常好用:

    use gaj
    select * from dbo.j_module_article where DateDiff (day,adddate,getdate())<3

    写上 以备以后需要.

  • 相关阅读:
    线程池。
    等待唤醒机制。
    第一册:lesson 131.
    线程同步机制。
    第一册: lesson 129。
    线程实现方式。
    第一册:lesson 125.
    第一册:Lesson 123.
    黄渤的谈话。
    K3 KFO 手册
  • 原文地址:https://www.cnblogs.com/2008pp/p/2375136.html
Copyright © 2011-2022 走看看