amount of days between dates

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Post Reply
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Hello everyone, but once I depend on the wisdom of you, people I have a little urgent problem I have to solve until Friday night so I ask an urgent help!

Good I have the date and date of a contract

I need a select that brings me to date | ??????? | Datafim

In this | ??? | It would be the following wanted the amount of days between a date and the other but using the decode as follows that it returns the days between them and accurent at the end the word days ex: 252 days.

Personally before hand I thank everyone who will readily respond.

Brigadão.
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

And ai carlos, beleza ??

Here is an example.

Select all

 
  1  SELECT (   TO_CHAR (data_inicial, 'dd/mm/yyyy') 
  2          || ' | ' 
  3          || FLOOR (TRUNC (data_final) - TRUNC (data_inicial)) 
  4          || ' dias | ' 
  5          || TO_CHAR (data_final, 'dd/mm/yyyy') 
  6         ) dias 
  7*   FROM mens_erro2 
SQL> / 
 
DIAS 
----------------------------------------------------------------------- 
29/11/2007 | 21 dias | 20/12/2007 
[] 's
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

My friend Cristiano (tineks), man I'm speechless, I was flustered with the rope in the neck to deliver this select containing this calculation and did not even know where it starts, face brigadão for the affection, I have noticed that you have helped me far beyond remaining staff. Look I hope someday for helping as you have given a force to the staff, if one day you think if it's worth playing a while forum to remember me, because it's worth a lot here people who are only breastanding knowledge and people who are in search of help, sometimes often resort to various sites without being answered or often destracted, you are to be congratulated once again thank you!
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

Cristiano (Tineks)

Date function just for me to understand better?
Tineks
Rank: DBA Sênior
Rank: DBA Sênior
Posts: 365
Joined: Tue, 24 May 2005 2:24 pm
Location: Araraquara - SP
Cristiano (Tineks)
Araraquara - SP

And then Carlos beleza ??

face, thank you and me is a pleasure to be here in the forum, the way you guys learn I learn tb has much q thing I do not know and I have just apredendo seeing other posts, I q forum is one of the best places to learn, diversity of q doubts have is very large, so we always end up seeing something here q shortly afterwards ended up using ...

then, speaking the select,
u said I needed the amount of days, for that u can make a subtraction between the dates, the result will be as follows.

Select all

 
SQL> SELECT DATA_INICIAL, DATA_FINAL-DATA_INICIAL, DATA_FINAL FROM MENS_ERRO2 
  2  / 
 
DATA_INIC DATA_FINAL-DATA_INICIAL DATA_FINA 
--------- ----------------------- --------- 
29-NOV-07               21.001389 20-DEC-07 
like you can see the days nro came broken, I put the FLOOR to force it to round down, for example.

Select all

 
SQL> SELECT DATA_INICIAL, FLOOR(DATA_FINAL-DATA_INICIAL), DATA_FINAL FROM MENS_ERRO2 
  2   
SQL> / 
 
DATA_INIC FLOOR(DATA_FINAL-DATA_INICIAL) DATA_FINA 
--------- ------------------------------ --------- 
29-NOV-07                             21 20-DEC-07 
In the consultation I sent you I tb tribles the dates, so it does not take into account the time, minute and second ..
and the rest of the consultation was only concatenating the dates with this result there. : D

[] 's !!
carlos12
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 123
Joined: Wed, 24 Oct 2007 4:31 pm
Location: rio

valeu face once again for the tip, I'm your fan !!
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests