oracle hh24 mi ss.ff,How to convert date to timestamp(DD-MON-YYYY HH24:MI:SS.FF format) in oracle?

I tried below query but its not working

select

TO_TIMESTAMP(ColumnName(Data type Date), 'DD-MON-YYYYHH24:MI:SS.FF')

from TableName

where Changedate>='01-Dec-2015'

*I need the result without AM/PM indication.

Result will be 15-DEC-2015 15:16:42.045016

# Answer 1

4d350fd91e33782268f371d7edaa8a76.png

If I got your question right you need the output in the mentioned Format. That would be a conversion to character

select to_char(cast(sysdate as timestamp),'DD-MON-YYYY HH24:MI:SS.FF') from dual

Of course in the above the FF would also always be 000000

But if you have a timestamp variable you would not cast

select to_char(systimestamp,'DD-MON-YYYY HH24:MI:SS.FF') from dual

# Answer 2

select to_char(cast(sysdate as timestamp),'DD-MON-YYYY HH24:MI:SS') from dual

# Answer 3

I think you need not have to convert to timestamp if your column is of date data type. Also there is no need to use .FF as date will not have time in milliseconds.

select to_char(ColumnName(Data type Date), 'DD-MON-YYYYHH24:MI:SS.FF') from dual;

# Answer 4

These are 2 ways you can try:

to_char(cast(sysdate as timestamp), 'YYYY-MM-DD HH:MM:SS.ff')

or:

to_char(to_Date(sysdate, 'DD-MON-YY'), 'YYYY-MM-DD HH:MM:SS')

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值