少年阿賓

          那些青春的歲月

            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 閱讀(485) 評論(0)  編輯  收藏 所屬分類: mysql
          主站蜘蛛池模板: 东港市| 霍州市| 鄂托克前旗| 泌阳县| 延寿县| 南充市| 手游| 长宁县| 贡嘎县| 客服| 东山县| 苍溪县| 汤原县| 即墨市| 海南省| 巴彦淖尔市| 淳安县| 罗江县| 分宜县| 乌拉特后旗| 开鲁县| 萝北县| 汪清县| 嘉鱼县| 安阳县| 竹北市| 银川市| 青州市| 安泽县| 枝江市| 多伦县| 湛江市| 固镇县| 隆安县| 安庆市| 长葛市| 吉首市| 聂荣县| 娱乐| 乐东| 苍南县|