oracle的时间
今天发现之前从oracle导出的数据时间格式很奇怪:
"ACTIVETIME","ACTIVITYID"
"2018-08-10 06:08:43","4001"
"2018-08-10 06:08:12","4001"
"2018-08-10 06:08:43","4001"
"2018-08-10 06:08:48","4001"
"2018-08-10 06:08:04","4001"
"2018-07-19 05:07:15","4001"
"2018-07-19 03:07:00","4001"
"2018-07-20 05:07:00","4001"
"2018-07-20 05:07:00","4001"
"2018-07-20 05:07:00","4001"
"2018-07-20 05:07:00","4001"
"2018-07-20 05:07:00","4001"
然后去看了下脚本:
select to_char(t.Activetime,'yyyy-MM-dd HH:mm:ss') Activetime,t.activityid from T_INVITER_RECORD t where t.ACTIVITYID = 4001;
这里oracle的时间格式不区分大小写,所以MM跟mm对oracle来说就是一样的事情,所以分钟就变成了月,全都是07了。正确的时间格式应该是yyyy-mm-dd,hh24:mi:ss,脚本改下:
select to_char(t.Activetime,'yyyy-mm-dd,hh24:mi:ss') Activetime,t.activityid from T_INVITER_RECORD t where t.ACTIVITYID = 4001;
输出结果正常了:
ACTIVETIME ACTIVITYID
2018-08-10,18:01:43 4001
2018-08-10,18:01:12 4001
2018-08-10,18:00:43 4001
2018-08-10,18:02:48 4001
2018-08-10,18:02:04 4001
2018-07-19,17:38:15 4001
2018-07-19,15:46:00 4001
2018-07-20,17:00:00 4001
2018-07-20,17:00:00 4001
2018-07-20,17:00:00 4001
2018-07-20,17:00:00 4001
2018-07-20,17:00:00 4001
2018-07-20,17:00:00 4001