Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 Other Topics
 please help whit select where date for oracle

Author  Topic 

Frank
Starting Member

3 Posts

Posted - 2002-05-14 : 19:03:07
Here is my code


SELECT nvl(sum(qte_recu),0) INTO mo_7 FROM cmdfn_detail a,cmdfn b
WHERE a.no_produit_cardex = eNo_Prod and to_char(b.date_cmd,'MM')= to_char (sysdate,'MM')-6 and a.no_cmd=b.no_cmd ;


My problem is when the result of sysdate,MM -6 came under 1 the month is not valide. How can i do make this code works for selecting 6,7 or 8 month ago from the day i do
the query..?



thanks


Frank

Edit by Merkin : Put in the right forum.



Edited by - merkin on 05/14/2002 19:18:27

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2002-05-14 : 19:19:31
You might be better off asking this on an Oracle site. Posting in the SQLteam article discussion area (where I moved it from) won't help too much.

Damian
Go to Top of Page

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-05-14 : 22:02:26
I can't remember whether Oracle has a datediff type function, but if it does, that's what it's there for...

Instead of
(sysdate, 'MM')-6
I think you do something like...
ADD_MONTHS(sysdate, -6)

HT as they say H






--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"

Edited by - rrb on 05/14/2002 22:03:06
Go to Top of Page
   

- Advertisement -