Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

comparing dates giving unexpected error

Status
Not open for further replies.

alh1002

Technical User
Mar 27, 2006
41
US
So I have a table where ladder_date is stored as Date/Time

I then have the following query
Select B.book_name,B.ladder_date,B.BOM,B.NAV,B.gMTDRT,B.gMTDPER,B.PreviousDay,Base, B.gTDRT,B.gTDCHANGEPER, (select ((Exp(SUM(Log(1+A.gTDCHANGEPER/100)))-1)*100) AS YTD

from Daily_tt A
where B.ladder_date < A.ladder_date)
from Daily_tt B;


and it is returning an error, "Data type mismatch in criteria expression"

but if I use an "=" it works, but I want the less than sign.

Any thoughts on why this is happening?
 
Code:
Select B.book_name,B.ladder_date,B.BOM,B.NAV,B.gMTDRT,B.gMTDPER,B.PreviousDay,Base, B.gTDRT,B.gTDCHANGEPER, 

(select Exp(SUM(Log(1+A.gTDCHANGEPER/100)))-1)*100 
 from Daily_tt A
 where B.ladder_date < A.ladder_date
   [COLOR=red]AND A.gTDCHANGEPER IS NOT NULL) AS YTD
[/color]

from Daily_tt B;

or

Code:
Select B.book_name,B.ladder_date,B.BOM,B.NAV,B.gMTDRT,B.gMTDPER,B.PreviousDay,Base, B.gTDRT,B.gTDCHANGEPER, 

Exp(SUM(Log(1+A.gTDCHANGEPER/100)))-1)*100  AS YTD

FROM Daily_tt B INNER JOIN Daily_tt A
     ON A.ladder_date > B.ladder_date

Where A.gTDCHANGEPER IS NOT NULL

Group By B.book_name,B.ladder_date,B.BOM,B.NAV,B.gMTDRT,B.gMTDPER,
B.PreviousDay,Base, B.gTDRT, B.gTDCHANGEPER
Which makes sense only of Ladder_Date is a unique key.

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top