前天发过这个贴子:http://topic.csdn.net/u/20080113/20/58cc0998-6d16-4194-bd4c-15c0bd86b8d7.html
谈的不算技术问题,访问的人那么多,相信大家都看过那个网站!里面有个时间算法用到很多!
就是返回  40分钟前上传 N秒前上传 N分钟前上传 N小时前上传 N天前上传 N个月前上传!N年前上传!
我知道方法很多!大家说说吧!我的方法也有待改进的!

解决方案 »

  1.   

    SELECT COUNT(*) FROM 上传表 WHERE DATEDIFF(second,上传时间,GetDate())<=N分钟*60秒 or N小时*3600秒不行吗?
      

  2.   

    public abstract class UpFileTime
        {
            public abstract string GetUpFileTime();
            
        }    public class Second : UpFileTime
        {
            public override string GetUpFileTime()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }    public class Minute : UpFileTime
        {
            public override string GetUpFileTime()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }    public class Hour : UpFileTime
        {
            public override string GetUpFileTime()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }    public class Day : UpFileTime
        {
            public override string GetUpFileTime()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }    public class Month : UpFileTime
        {
            public override string GetUpFileTime()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }    public class Yeah : UpFileTime
        {
            public override string GetUpFileTime()
            {
                throw new Exception("The method or operation is not implemented.");
            }
        }    public class CreateClass
        {
           public static UpFileTime SelectObject(string id)
            {
                if(id == "...")
                {
                   //......
                }
                //.....
            }
        }    public class Test
        {
            private void OnClick()
            {
                UpFileTime ft = CreateClass.SelectObject("XXXXXX");
                ft.GetUpFileTime();
            }
        }