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
  

Poston Thu, 29 Nov 2007 3:30 pm

Hello guys, but once depend on the wisdom of vocês, guys I'vê got a little problem I have to kind of urgent resolve until Friday night so I ask an urgent help!

Well I have the datainicio and the datafim of a contract need a select that bring me the datainicio |??????? | datafim in the |??? | would be the following wanted the amount of days between a date and the other but using the decode as follows it returns the days between them and acrecente at the end the word DAY ex: 252 days.

Staff would like to thank all hand ante which will respond promptly.

Brigadão.
carlos12
Location: rio

Poston Thu, 29 Nov 2007 4:02 pm

Hey carlos, beleza?

There follows an example.

Code: 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
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP

Poston Thu, 29 Nov 2007 9:49 pm

My friend Christian (Tineks), man I am speechless, I was flustered with the rope around his neck to deliver this select containing this calculation and didn't know where to start, man brigadao for caring, I have noticed that u have helped me far beyond the rest of the staff. Look I hope one day to help as well as vocês has given a force ai personally, if one day you wonder if it's worth devoting some time to this forum remember me as worth much here has people who are only changing knowledge and people who are seeking help, sometimes very often resort to various websites without being answered or much of the time until destratadas, you are to be congratulated once again THANK YOU VERY MUCH!
carlos12
Location: rio

Poston Thu, 29 Nov 2007 9:54 pm

Christian (Tineks) I ALMOST FORGOT HAHAH IT'S ALMOST MIDNIGHT And I'M At HOME RESTING Or THOUGHT In SELECT TOMORROW, Lol U COULD GIVE ME A REVE HAVE REASONS On EACH FORM USED In THIS ROLE To DATE ME BETTER UNDERSTAND?
carlos12
Location: rio

Poston Fri, 30 Nov 2007 7:30 am

And Carlos beleza?

Dude, thank you and for me it's a pleasure to be here on the Forum, the way you learn I learn também, there's a lot that I don't know and I end up learning seeing the other posts, I think the Forum is one of the best places to learn, the diversity of questions q is very large, so we always end up seeing something here q shortly afterwards we ended up using ...

Then, speaking of the select, you said I needed amount of days, for that u can do a subtracao between dates, the result will be the following.
Code: 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
as you can see the nro of days came broken, I put the FLOOR to force him to round down, for example.
Code: 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 query I sent you I também trunquei dates, so it does not take into consideration the hour, minute, and second.
and the rest of the query was just concatenate dates with this result there. :D

[]'s!!
Tineks
Location: Araraquara - SP

Cristiano (Tineks)
Araraquara - SP

Poston Fri, 30 Nov 2007 9:22 am

valeu GUY ONCE AGAIN FOR THE TIP, I'M A FAN!!
carlos12
Location: rio


  • See also
    Replies
    Views
    Last Post


Return to SQL

Who is online

Users browsing this forum: No registered users and 4 guests