zoukankan      html  css  js  c++  java
  • mysql和oracle日期和字符相互转换

    一、mysql日期和字符相互转换

    1.1、日期——>字符
     
    date_format(date,'%Y-%m-%d')    
    oracle中的to_char(); 
     
    1.2、字符——>日期
    str_to_date(date,'%Y-%m-%d')     
    oracle中的to_date(); 
     
    1.3、mysql中的格式
     
    %Y:代表4位的年份 
    %y:代表2为的年份 
     
    %m:代表月, 格式为(01……12)  
    %c:代表月, 格式为(1……12) 
     
    %d:代表月份中的天数,格式为(00……31)  
    %e:代表月份中的天数, 格式为(0……31) 
     
    %H:代表小时,格式为(00……23)  
    %k:代表 小时,格式为(0……23)  
    %h: 代表小时,格式为(01……12)  
    %I: 代表小时,格式为(01……12)  
    %l :代表小时,格式为(1……12) 
      
    %i: 代表分钟, 格式为(00……59) 
     
    %r:代表 时间,格式为12 小时(hh:mm:ss [AP]M)  
    %T:代表 时间,格式为24 小时(hh:mm:ss) 
     
    二、oracle日期和字符相互转换
     
    2.1、日期——>字符
      
    to_char(); 
     
    2.2、字符——>日期
     
    to_date('str','format'); 
     
    2.3、oracle中的格式
     
    D 一周中的天 (1-7)
    DAY 天的名称 (Sunday - Saturday)
    DD 一月中的天 (1 - 31)
    DDD 一年中的天 (1 - 366)
    DY 天的缩写 (Sun - Sat)
    HH 一天中的小时 (1 - 12)
    HH24 一天中的小时 (0 - 23)
    MI 分钟 (0-59)
    MM 月 (01-12)
    MON 月名称的缩写
    MONTH 月的名称
    SS 秒 (0-59)
    YYYY 4 个数字表示的年 
  • 相关阅读:
    如何通过Restful API的方式读取SAP Commerce Cloud的Product图片
    Permute Digits
    Browser
    Jamie and Alarm Snooze
    Perfect Squares
    Color the ball
    Stars
    1086. Tree Traversals Again (25)
    1085. Perfect Sequence (25)
    1083. List Grades (25)
  • 原文地址:https://www.cnblogs.com/geekdc/p/5311414.html
Copyright © 2011-2022 走看看