Assuming this has a simple solution, but I can't find it.
I'm trying to do some logic on a DATE field in Oracle. My desire is to take a DATE field and subtract X hours from it.
For instance: SELECT A.MyDATE - 100 Hours from dual;
however, I need a result in a timestamp format 'YYYY-MM-DD hh:mm'.
I've tried CAST(A.MyDATE as TIMESTAMP) - NUMTODSINTERVAL(100/24,'day') however it didn't work.
I found out that the issue is that the MyDATE field when cast to a timestamp still contained some residual time elements. How can I reset these??
Thanks!
MyDateis on rather than 100 hours from whatever timeMyDatehas? What data type do you want your query to return? The query you posted returns atimestampbut if you're talking about wanting a particular format that implies that you want to return avarchar2.2013-01-15and I was hoping for to get2013-01-10 20:00as a result. I'm not getting this - I'm getting something like2013-01-10 21:49. I found out that 'MyDate' when converted to a timestamp hold hours and minutes instead of 00:00 in it - not sure why. SO... I'm trying to zero out the time portion of MyDate after timestamp conversion, but I don't know how to do it.