获得系统当前时间
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()));
查询结果: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()));
相关文章推荐
- [iOS]获得当前系统时间(当前时区)
- C++中获得当前系统时间
- C++中获得当前系统时间
- C++中获得当前系统时间
- java获得系统当前时间
- ios 获得当前的系统时间和日期
- java中获得系统当前时间
- java获取获得Timestamp类型的当前系统时间
- android SharedPreference的用法及获得系统当前时间
- Android获得当前系统时间、星期几、周几
- VC++获得当前系统时间的几种方案
- [转]C/C++中获得当前系统时间
- Android获得当前系统时间、星期几、周几、十二小时制、二十四小时制
- java获得当前系统时间三种方法
- [VC++]VC中如何获得当前系统时间
- VC++获得当前系统时间的几种方案
- asp 如何获得系统当前时间 (包括分)
- 获得系统当前时间戳
- Android 获得系统当前时间
- 获得当前系统时间(JAVA)