Oracle时间操作

一.插入当前日期

//构造系统时间的字符串
String createDate =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());


insert into P_USER_LOG
  (USERID, HANDLEACT, IP, LOGDATE)
values
  ('1',
   '删除权限组:7676767',
   '127.0.0.1',
   to_date('createDate', 'yyyy-mm-dd hh24:mi:ss'))
   
   
二.如何使查询出的日期格式化 :to_char(LOGDATE,'yyyy-mm-dd hh24:mi:ss')
"SELECT B.* FROM
   (SELECT USERID,HANDLEACT,IP,to_char(LOGDATE,'yyyy-mm-dd hh24:mi:ss') as logdate, ROWNUM RN 
    FROM 
   (SELECT * FROM P_USER_LOG order by LOGDATE desc ) A 
   WHERE ROWNUM <= "+(start+len)+"
   )B
where B.RN>="+start+"";   

你可能感兴趣的:(oracle,sql)