zoukankan      html  css  js  c++  java
  • mysql 日期转换sql函数

    mysql提供了两个函数:

              from_unixtime(time_stamp)   ->  将时间戳转换为日期

              unix_timestamp(date)             ->  将指定的日期或者日期字符串转换为时间戳

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    [plain]
    select from_unixtime(1382544000); 
    +---------------------------+ 
    | from_unixtime(1382544000) | 
    +---------------------------+ 
    | 2013-10-24 00:00:00       | 
    +---------------------------+ 
    如: unix_timestamp(date)
      
    [plain]
    select unix_timestamp(date('2013-10-24')); 
    +------------------------------------+ 
    | unix_timestamp(date('2013-10-24')) | 
    +------------------------------------+ 
    |                         1382544000 | 
    +------------------------------------+ 
      
    如果要查询当天的订单的记录:
    [plain]
    select count(*) from b_order Where  date_format(from_unixtime(create_time),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d'
      
    也可以这样:
    [plain]
    select count(*) from b_order Where  create_time >= unix_timestamp('2013-10-24 00:00:00') and create_time <=  unix_timestamp('2013-10-24 23:59:59') ; 
  • 相关阅读:
    poj1459(多源点网络流)
    poj 2480
    poj1850和poj1496(组合数)
    poj3252(组合数)
    hdu1452(逆元)
    因子和与因子个数
    poj 2478(欧拉函数打表)
    p3807(lucas定理)
    F-有趣的数字(组合数+逆元)
    《Java并发编程的艺术》Java并发机制的底层实现原理(二)
  • 原文地址:https://www.cnblogs.com/gyrgyr/p/11240126.html
Copyright © 2011-2022 走看看