日期格式相关
2016-03-01 14:51
316 查看
字符替换
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'年','/');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'月','/');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'日','
');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'时',':');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'分',':00');
字符提取
update tzincident2015_yuan
set发生时间_月=(substr(发生时间,instr(发生时间,'/',1,1)+1,
instr(发生时间,'/',1,2)-1-instr(发生时间,'/',1,1)));
update tzincident2015_yuan
set发生时间_日=(substr(发生时间,instr(发生时间,'/',1,2)+1,
instr(发生时间,' ',1,1)-1-instr(发生时间,'/',1,2)));
update tzincident2015_yuan
set发生时间_时=(substr(发生时间,instr(发生时间,'
',1,1)+1,
instr(发生时间,':',1,1)-1-instr(发生时间,'
',1,1)));
字符判断
Select to_char(sysdate,'ss')
from dual;取当前时间秒部分
Select to_char(sysdate,'mi')
from dual;取当前时间分钟部分
Select to_char(sysdate,'HH24')
from dual;取当前时间秒小时部分
Select to_char(sysdate,'DD')
from dual;取当前时间日期部分
Select to_char(sysdate,'MM')
from dual;取当前时间月部分
Select to_char(sysdate,'YYYY')
from dual;取当前时间年部分
Select to_char(sysdate,'w')
from dual;取当前时间是一个月中的第几周(从1日开始算)
Select to_char(sysdate,'ww')
from dual;取当前时间是一年中的第几周(从1.1开始算)
Select to_char(sysdate,'iw')
from dual;取当前时间是一年中的第几周(按实际日历的)
Select to_char(sysdate,'d')
from dual;取当前时间是一周的第几天,从星期天开始,周六结束
Select to_char(sysdate,'day')
from dual; 取当前日是星期几,和数据库设置的字符集有关,会输出'Tuesday'
Select to_char(sysdate,'ddd')
from dual ;当前日是一年中的第几天
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'年','/');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'月','/');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'日','
');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'时',':');
updatetzincident2015_yuan s
set s.发生时间=replace(s.发生时间,'分',':00');
字符提取
update tzincident2015_yuan
set发生时间_月=(substr(发生时间,instr(发生时间,'/',1,1)+1,
instr(发生时间,'/',1,2)-1-instr(发生时间,'/',1,1)));
update tzincident2015_yuan
set发生时间_日=(substr(发生时间,instr(发生时间,'/',1,2)+1,
instr(发生时间,' ',1,1)-1-instr(发生时间,'/',1,2)));
update tzincident2015_yuan
set发生时间_时=(substr(发生时间,instr(发生时间,'
',1,1)+1,
instr(发生时间,':',1,1)-1-instr(发生时间,'
',1,1)));
字符判断
Select to_char(sysdate,'ss')
from dual;取当前时间秒部分
Select to_char(sysdate,'mi')
from dual;取当前时间分钟部分
Select to_char(sysdate,'HH24')
from dual;取当前时间秒小时部分
Select to_char(sysdate,'DD')
from dual;取当前时间日期部分
Select to_char(sysdate,'MM')
from dual;取当前时间月部分
Select to_char(sysdate,'YYYY')
from dual;取当前时间年部分
Select to_char(sysdate,'w')
from dual;取当前时间是一个月中的第几周(从1日开始算)
Select to_char(sysdate,'ww')
from dual;取当前时间是一年中的第几周(从1.1开始算)
Select to_char(sysdate,'iw')
from dual;取当前时间是一年中的第几周(按实际日历的)
Select to_char(sysdate,'d')
from dual;取当前时间是一周的第几天,从星期天开始,周六结束
Select to_char(sysdate,'day')
from dual; 取当前日是星期几,和数据库设置的字符集有关,会输出'Tuesday'
Select to_char(sysdate,'ddd')
from dual ;当前日是一年中的第几天
相关文章推荐
- Yii2 where
- PAT (Basic Level)1024. 科学计数法
- Tomcat7的安装
- discuz代码分析之左连接 t1 left join t2 on t1.id=t2.uid where...
- 206. Reverse Linked List
- 通过句柄获取或遍历SysListView32和SysTreeView32控件的数据信息
- 《大型网站技术架构》读书笔记四:瞬时响应之网站的高性能架构
- 一起talk GDB吧(第七回:GDB监视功能)
- hadoop io PART1
- 前端之JavaScript第四天学习(10)-JavaScript-运算符
- android 跨进程通讯 AIDL
- 集合工具类:Collections
- [oracle] 设置PL/SQL Developer 字符集
- Git使用流程
- V-Play 文档翻译 Page
- 利用原生js提升jquery选择器的性能
- java多线程锁种类
- GCC wiki Visibility
- Android注解
- bananapi之system安装