Home » SQL & PL/SQL » SQL & PL/SQL » calculate Days Between
calculate Days Between [message #403863] Tue, 19 May 2009 04:57 Go to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
i have two dates

start date and end date

i need to find days between start date and end date

pls help

date format is char yyyymmdd
Re: calculate Days Between [message #403864 is a reply to message #403863] Tue, 19 May 2009 04:59 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Subtract and trunc.

By
Vamsi
Re: calculate Days Between [message #403865 is a reply to message #403863] Tue, 19 May 2009 05:00 Go to previous messageGo to next message
cookiemonster
Messages: 12403
Registered: September 2008
Location: Rainy Manchester
Senior Member
Convert them to date datatype and subtract.
Re: calculate Days Between [message #403866 is a reply to message #403863] Tue, 19 May 2009 05:06 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
Invalid number state error ??

i converted to date using to_date

ORA -01722

[Updated on: Tue, 19 May 2009 05:12]

Report message to a moderator

Re: calculate Days Between [message #403872 is a reply to message #403866] Tue, 19 May 2009 05:27 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What help do you expect posting no information on what you did?
Don't do something that is wrong.

Regards
Michel
Re: calculate Days Between [message #403882 is a reply to message #403863] Tue, 19 May 2009 06:02 Go to previous messageGo to next message
sajidrazmi
Messages: 47
Registered: August 2008
Location: oman
Member
Write Code lIke This
Select To_Date(:End_Date,'DD/MM/YYYY') - To_Date(:Star_Date,'DD/MM/YYYY')+1 From Dual
Re: calculate Days Between [message #403883 is a reply to message #403863] Tue, 19 May 2009 06:05 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
Thanks all for the help


I got it using trim Smile

Re: calculate Days Between [message #403888 is a reply to message #403883] Tue, 19 May 2009 06:29 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
avrillavinge wrote on Tue, 19 May 2009 12:05
Thanks all for the help


I got it using trim Smile



Then you did it wrong and your code will eventually fail.
Re: calculate Days Between [message #403890 is a reply to message #403863] Tue, 19 May 2009 06:39 Go to previous messageGo to next message
avrillavinge
Messages: 98
Registered: July 2007
Member
yes using the truc to_date

and trim

it was a joint efort thats how igot it

Thanks all for the Help

great forum
Re: calculate Days Between [message #403901 is a reply to message #403890] Tue, 19 May 2009 08:27 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
Reread pablolee's answer.
If you needed to use TRIM, you either described your situation wrongly or you made an error in your solution.
Are your two dates really varchar2? Or are they of datatype DATE after all?
Previous Topic: Help about SQL Query
Next Topic: calling type inside package
Goto Forum:
  


Current Time: Sat Dec 03 08:21:39 CST 2016

Total time taken to generate the page: 0.11850 seconds