您的位置:首页 > 其它

获得系统当前时间

2009-07-05 16:15 246 查看
select to_char(sysdate,'yyyy-MM-dd'),t.st_pass_type from dual,t_pass t

查询结果:2009-07-05 _ 1

查看当前的timestamp时间是CURRENT_TIMESTAMP
select current_timestamp from dual;

查询结果:05-7月 -09 04.34.21.921000 (下午 +08:00)[timestamp(6) 不要括号部分]

当前时间减去7分钟的时间
select sysdate,sysdate - interval '7' MINUTE from dual
当前时间减去7小时的时间
select sysdate - interval '7' hour from dual
当前时间减去7天的时间
select sysdate - interval '7' day from dual
当前时间减去7月的时间
select sysdate,sysdate - interval '7' month from dual
当前时间减去7年的时间
select sysdate,sysdate - interval '7' year from dual
时间间隔乘以一个数字
select sysdate,sysdate - 8 *interval '2' hour from dual

2.日期到字符操作

select sysdate,to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual
select sysdate,to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual

3. 字符到日期操作

select to_date('2003-10-17 21:15:37','yyyy-mm-dd hh24:mi:ss') from dual

4、数据库中保存当前时间

new Timestamp(new Date().getTime())

System.out.print(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: