Re: Subtract Null = Error
Look at the IsNumeric function HTH Dick At 9:41 AM +0100 8/7/01, Gryphawk wrote: Is there anyway to get around this such as an If Recordset.TOTAL = nothing, Then [don't subtract]? ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Subtract Null = Error
HI Something like this should do it Depending whether the variable is null or has a value cf will evaulate which one to use automatically cfif Recordset2.Total is NULL Statements to deal with when the value is null cfelse cfoutputcfset newTotal =(Recordset2.TOTAL - Recordset1.TOTAL)#newTotal# /cfoutput /cfif regards Mark Smyth Macromedia Certified ColdFusion Developer Systems Union eBusiness Solutions 00 44 1865 880800 -Original Message- From: Gryphawk [mailto:[EMAIL PROTECTED]] Sent: 07 August 2001 09:41 To: CF-Talk Subject: Subtract Null = Error Hi there I was hoping you could help me with a problem - I have a calculated value from the following code: cfoutputcfset newTotal =(Recordset2.TOTAL - Recordset1.TOTAL)#newTotal# /cfoutput Which works just fine when the Recordset2.TOTAL and Recordset1.TOTAL are populated by the SQL (as set by search parameters on a previous page). However, on occasion Recordset2.Total is equal to nothing (null?) while Recordset1.TOTAL has a value due to the search string, and when this happens, CF throws an error which reads: An error occurred while evaluating the expression: newTotal =(Recordset2.TOTAL - Recordset1.TOTAL) Error near line 316, column 17. Cannot convert to number. Is there anyway to get around this such as an If Recordset.TOTAL = nothing, Then [don't subtract]? My apologies that I am only just starting to learn how to write coded stuff. Many thanks, Gryphawk ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Subtract Null = Error
Or actually, if the variable isn't even created you'll have to: cfif isDefined(Recordset2.Total) cfoutputcfset newTotal =(Recordset2.TOTAL - Recordset1.TOTAL)#newTotal# /cfoutput cfelse Statements to deal with when the value is null /cfif -Original Message- From: Mark Smyth Sent: 07 August 2001 09:52 To: CF-Talk Subject: RE: Subtract Null = Error HI Something like this should do it Depending whether the variable is null or has a value cf will evaulate which one to use automatically cfif Recordset2.Total is NULL Statements to deal with when the value is null cfelse cfoutputcfset newTotal =(Recordset2.TOTAL - Recordset1.TOTAL)#newTotal# /cfoutput /cfif regards Mark Smyth Macromedia Certified ColdFusion Developer Systems Union eBusiness Solutions 00 44 1865 880800 -Original Message- From: Gryphawk [mailto:[EMAIL PROTECTED]] Sent: 07 August 2001 09:41 To: CF-Talk Subject: Subtract Null = Error Hi there I was hoping you could help me with a problem - I have a calculated value from the following code: cfoutputcfset newTotal =(Recordset2.TOTAL - Recordset1.TOTAL)#newTotal# /cfoutput Which works just fine when the Recordset2.TOTAL and Recordset1.TOTAL are populated by the SQL (as set by search parameters on a previous page). However, on occasion Recordset2.Total is equal to nothing (null?) while Recordset1.TOTAL has a value due to the search string, and when this happens, CF throws an error which reads: An error occurred while evaluating the expression: newTotal =(Recordset2.TOTAL - Recordset1.TOTAL) Error near line 316, column 17. Cannot convert to number. Is there anyway to get around this such as an If Recordset.TOTAL = nothing, Then [don't subtract]? My apologies that I am only just starting to learn how to write coded stuff. Many thanks, Gryphawk ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists
RE: Subtract Null = Error
check out the NVL function. i'm assuming this is SQL server. if you NVL(total, 0) in your sql query, it will substitute 0 for the NULL values. i'm also assuming that negative #newtotal# is ok. chris olive, cio cresco technologies [EMAIL PROTECTED] http://www.crescotech.com -Original Message- From: Gryphawk [mailto:[EMAIL PROTECTED]] Sent: Tuesday, August 07, 2001 4:41 AM To: CF-Talk Subject: Subtract Null = Error Hi there I was hoping you could help me with a problem - I have a calculated value from the following code: cfoutputcfset newTotal =(Recordset2.TOTAL - Recordset1.TOTAL)#newTotal# /cfoutput Which works just fine when the Recordset2.TOTAL and Recordset1.TOTAL are populated by the SQL (as set by search parameters on a previous page). However, on occasion Recordset2.Total is equal to nothing (null?) while Recordset1.TOTAL has a value due to the search string, and when this happens, CF throws an error which reads: An error occurred while evaluating the expression: newTotal =(Recordset2.TOTAL - Recordset1.TOTAL) Error near line 316, column 17. Cannot convert to number. Is there anyway to get around this such as an If Recordset.TOTAL = nothing, Then [don't subtract]? My apologies that I am only just starting to learn how to write coded stuff. Many thanks, Gryphawk ~~ Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists