急急PHP,資料庫中createtime欄位類型為datetime,怎樣根據這個查詢一段時間內的資料

來源:互聯網
上載者:User
資料庫中createtime欄位類型為datetime,是年月日時分秒,怎樣把他轉換成時間戳記?資料很多,一條好轉換,可是那麼多怎麼辦?


回複討論(解決方案)

select unix_timestamp('2011-4-19 12:00:00');

select unix_timestamp('2011-4-19 12:00:00');

我資料庫不是時間戳記形式,而是datetime形式

我資料庫不是時間戳記形式,而是datetime形式
你不是說要轉成時間戳記嗎?unix_timestamp可以將你的datetime格式轉換成時間戳記啊


我資料庫不是時間戳記形式,而是datetime形式
你不是說要轉成時間戳記嗎?unix_timestamp可以將你的datetime格式轉換成時間戳記啊
資料庫裡不是一條資料,那麼多資料怎麼轉

資料庫裡不是一條資料,那麼多資料怎麼轉
select unix_timestamp(time欄位);time欄位是資料庫中你要轉換的時間欄位 他會全部都轉的

直接比較就行了,可以不用轉

select * from table1 where create_time>'2014-03-21 00:00:00'

查詢可以直接比較
例如:select * from table where createtime>='2014-01-01 00:00:00' and creattime<'2014-01-31 00:00:00';

如果要批量顯示可以這樣
select *, unix_timestamp(createtime) as createtime from table;

select * from table where createtime>='2014-01-01 00:00:00' and creattime<'2014-01-31 00:00:00';

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.