PHP SQL 篩選時間

需要用日期來篩選指定日期區間的資料,剛好看到艾倫郭寫的這一篇,用了BETWEEN我覺得還蠻好用的,此篇文章也寫了好幾種方式,十分受用~


若SQL Server裡的 table 裡有一個日期欄位,只會放日期,那麼您可以寫成
SELECT …. FROM xxx WHERE xxx=’2008/1/15′SELECT …. FROM xxx WHERE xxx BETWEEN ‘2008/1/15’ AND ‘2008/1/20’

若日期欄位有包含時間, 由於時間可能值為 2008/1/15 23:59:59.50 如果您想找 2008/1/15 這一天裡的所有記錄(不拘時間), 卻將篩選條件寫成
SELECT …. FROM xxx WHERE xxx=’2008/1/15′ –>會找不到符合的記錄
SELECT …. FROM xxx WHERE xxx BETWEEN ‘2008/1/15’ AND ‘2008/1/16’ –>會連 2008/1/16 的記錄也被找到
SELECT …. FROM xxx WHERE xxx >= ‘2008/1/15’ AND xxx<= ‘2008/1/15 23:59:59’ –>若記錄值是2008/1/15 23:59:59.50 ,會找不到
因此,可以寫成
SELECT …. FROM xxx WHERE xxx >= ‘2008/1/15’ AND xxx < ‘2008/1/16’
就沒什麼問題了

本文出自
http://www.allenkuo.com/EBook5/view.aspx?TreeNodeID=13&id=374
[……]

閱讀更多

CSS 垂直水平居中最簡單的解決方案

垂直水平居中 ie9+

.child {
    position: absolute;
    top: 50%;  /* position the top  edge of the element at the middle of the parent */
    left: 50%; /* position the left edge of the element at the middle of the parent */

    transform: translate(-50%, -50%); /* This is a shorthand of
                                         translateX(-50%) and translateY(-50%) */
}

沿伸閱讀

http://stackoverflow.com/questions/8508275/how-to-center-a-position-absolute-element

[……]

閱讀更多