Calculate range of column with DATE format

Hi, experts:

I need a function to obtain from the next string:
'08/10/2013 06:27:02','dd/mm/yyyy hh24:mi:ss'

Open in new window

two values DATE:
'08/10/2013 03:00:00','dd/mm/yyyy hh24:mi:ss

Open in new window

'
and
'07/10/2013 03:00:00','dd/mm/yyyy hh24:mi:ss'

Open in new window

Could you help me with an example, please?

Thanks, regards!
carlino70Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
TRUNC the string to the day then add 3 hours.  For the second one, same thing then subtract 1 day.

select
      trunc(to_date('08/10/2013 06:27:02','dd/mm/yyyy hh24:mi:ss'),'DD') + 3/24,
      (trunc(to_date('08/10/2013 06:27:02','dd/mm/yyyy hh24:mi:ss'),'DD') + 3/24)-1
from dual;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
carlino70Author Commented:
ok, I'll try this.
Thanks
0
carlino70Author Commented:
It works with:
select
      trunc(to_date('08/10/2013 06:27:02','dd/mm/yyyy hh24:mi:ss'),'DD') + 3/24,
      (trunc(to_date('08/10/2013 06:27:02','dd/mm/yyyy hh24:mi:ss'),'DD') + 3/24)-1
from dual; 

Open in new window

But when I add him a name of column:
select min(utctime) minimo,
      (trunc(to_date(min(utctime),'dd/mm/yyyy hh24:mi:ss'),'DD') + 3/24)-1 DESDE,
      trunc(to_date(min(utctime),'dd/mm/yyyy hh24:mi:ss'),'DD') + 3/24 HASTA
from a_1dia_001;

Open in new window

I see:
MINIMO|DESDE|HASTA
28/09/2011|27/09/0011 03:00:00 a.m.|28/09/0011 03:00:00 a.m.
Why 0011 ? Should I add a year too?
0
slightwv (䄆 Netminder) Commented:
Confirm the format of the raw data.

My guess is that it doesn't match the format mask of: 'dd/mm/yyyy hh24:mi:ss'

The string values need to match the format mask 100%.
0
carlino70Author Commented:
It works with this format:

select min(utctime)+3/24, trunc(min(utctime),'dd') +1 +3/24 hasta, trunc(min(utctime),'dd')-1 +3/24 desde 
from a_1dia_001;  

Open in new window

I see;
MIN(UTCTIME)|HASTA|DESDE
28/09/2011|29/09/2011 03:00:00 a.m.|27/09/2011 03:00:00 a.m.

Open in new window


I think is OK for me, Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.