Oracle 中的 TO_DATE 和 TO_CHAR 函数
oracle 中 TO_DATE 函数的时间格式,以 2008-09-10 23:45:56 为例
格式
说明
显示值
备注
Year(年):
yy
two digits(两位年)
08
yyy
three digits(三位年)
008
yyyy
four digits(四位年)
2008
Month(月):
mm
number(两位月)
09
mon
abbreviated(字符集表示)
9月
若是英文版, 则显示 sep
month
spelled out(字符集表示)
9月
若是英文版, 则显示 september
Day(日):
dd
number(当月第几天)
10
ddd
number(当年第几天)
254
dy
abbreviated(当周第几天简写)
星期三
若是英文版, 则显示 wed
day
spelled out(当周第几天全写)
星期三
若是英文版, 则显示 wednesday
ddspth
spelled out, ordinal twelfth
tenth
Hour(时):
hh
two digits(12小时进制)
11
hh24
two digits(24小时进制)
23
Minute(分):
mi
two digits(60进制)
45
Second(秒):
ss
two digits(60进制)
56
其他:
Q
digit(季度)
3
WW
digit(当年第几周)
37
W
digit(当月第几周)
2
说明:
12小时格式下时间范围为: 1:00:00 - 12:59:59(12 小时制下的 12:59:59 对应 24 小时制下的 00:59:59)
24小时格式下时间范围为: 0:00:00 - 23:59:59
1. 日期和字符转换函数用法(to_date,to_char)
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期转化为字符串
select to_char(sysdate,'yyyy') as nowYear from dual; //获取时间的年
select to_char(sysdate,'mm') as nowMonth from dual; //获取时间的月
select to_char(sysdate,'dd') as nowDay from dual; //获取时间的日
select to_char(sysdate,'hh24') as nowHour from dual; //获取时间的时
select to_char(sysdate,'mi') as nowMinute from dual; //获取时间的分
select
相关文档:
一、准备特殊数据
create table t_escape(s varchar2(50));
--show define -- define "&" (hex 26)
--show escape -- escape off
set define off
set escape on
insert into t_escape values('string&text');
insert into t_escape values('string\&text');
insert into t_escape values('st ......
最近在项目报表中需要一个查询语句,用来统计符合某一列条件的其它几列的个数
比如有下面一个表结构:
需要在列D后面增加一列,统计在列A不为空,并且列B、C、D不为空的个数
经过自己试验,查找帮助,总算实现了上面的查询。
&nb ......
1.求部门中哪些人薪水最高:
select ename,sal
from emp join
(
select max(sal) max_sal, deptno
from emp
group by deptno
) t
on (emp.sal = t.max_sal and emp.deptno = t.deptno);
2.求部门平均薪水的等级:
select deptno, avg_sal, grade ......
Oracle 主要配置文件介绍:
profile文件,oratab 文件,数据库实例初始化文件 initSID.ora,监听配置文件, sqlnet.ora 文件,tnsnames.ora 文件
1.2 Oracle 主要配置文件介绍
1.2.1 /etc/profile 文件
系统级的环境变量一般在/etc/p ......
The following are number examples for the to_char function.
to_char(1210.73, '9999.9')
would return '1210.7'
to_char(1210.73, '9,999.99')
would return '1,210.73'
to_char(1210.73, '$9,999.00')
would return '$1,210.73'
to_char(21, '000099')
would return '000021'
The following is a list ......