少年阿賓

          那些青春的歲月

            BlogJava :: 首頁 :: 聯系 :: 聚合  :: 管理
            500 Posts :: 0 Stories :: 135 Comments :: 0 Trackbacks

          常用鏈接

          留言簿(22)

          我參與的團隊

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在MYSQL中插入當前時間:

            NOW()函數以`'YYYY-MM-DD HH:MM:SS'返回當前的日期時間,可以直接存到DATETIME字段中。
            CURDATE()以’YYYY-MM-DD’的格式返回今天的日期,可以直接存到DATE字段中。

            CURTIME()以’HH:MM:SS’的格式返回當前的時間,可以直接存到TIME字段中。
            例:insert into tablename (fieldname) values (now())

            now():以'yyyy-mm-dd hh:mm:ss'返回當前的日期時間,可以直接存到datetime字段中。
            curdate():’yyyy-mm-dd’的格式返回今天的日期,可以直接存到date字段中。

             

          //獲取Mysql系統時間   
          select now() as systime  ; 
          select sysdate() as systime  ; 
          select current_date as systime ;
          select current_time as systime ;
          select current_timestamp as systime ;
          select * from abing where to_days(sysdate())=to_days(createtime);   
          select * from abing where to_days(sysdate())=to_days(createtime);   
           select * from abing where str_to_date(now(),'%Y-%m-%d')=str_to_date(createtime,'%Y-%m-%d');  
          自己寫的例子,為了以后忘記了查詢用:
          use abin;
          create table abin1(
          id integer not null auto_increment,
          name varchar(100),
          create_time datetime ,
          update_time datetime ,
          constraint pk_abin1 primary key(id));
          insert into abin1(name,create_time,update_time) values ('abin1',now(),now());
          insert into abin1(name,create_time,update_time) values ('abin1',sysdate(),sysdate());




          posted on 2012-12-14 14:32 abin 閱讀(488) 評論(0)  編輯  收藏 所屬分類: mysql
          主站蜘蛛池模板: 台东县| 五华县| 安阳县| 广灵县| 八宿县| 卫辉市| 永善县| 翁源县| 佛坪县| 铁岭市| 盘山县| 浮梁县| 唐山市| 永清县| 斗六市| 江源县| 黑龙江省| 塔河县| 沂南县| 旬邑县| 壤塘县| 昭平县| 濮阳市| 丰镇市| 哈密市| 中牟县| 呼伦贝尔市| 右玉县| 渝北区| 梅河口市| 靖远县| 邵东县| 大港区| 三门县| 玛纳斯县| 民权县| 北碚区| 达日县| 手机| 五常市| 佳木斯市|