when i try to hard code the date i get the correct result somewhat only that it misses a record. here is what i mean by hard coding
<cfquery name="qBal" datasource="bond100"> SELECT ID_biodata, quater, datePaid, amountPaid, manFees FROM collections WHERE datePaid <= DateValue('4/20/2015 0:00:00 AM') AND ID_biodata = 1 AND quater = 'Quarter 1' ORDER BY datePaid </cfquery> <cfquery dbtype="query" name="results"> SELECT SUM(CAST(amountPaid as INTEGER) + CAST(manFees as INTEGER)) AS currentPaid FROM qBal </cfquery> that bring's me closer to the right answer but i am comparing with different dates from the database so am stuck.