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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to handle null values?

Status
Not open for further replies.

BarneyRubble

Programmer
Jun 28, 2004
1
GB
I have created an output query based on a number of criteria, that works OK. However, I would like to output a text value, if the value in the database is null ie 'target date not yet scheduled', if a target date has not yet been input into the database.

If anyone can help, I would be grateful
 
You can try this:

<cfif #datevalue# eq &quot;&quot;>
target date not yet scheduled
<cfelse>
#datevalue#
</cfif>


 
This should work with SQL Server (don't know about other DB's)....
[tt]
<CFQUERY NAME=&quot;Projects&quot; DATASOURCE=&quot;MyDB&quot;>
SELECT Project,
ISNULL(TargetDate, &quot;1/1/9999&quot;) AS TargetDate
FROM titles
</CFQUERY>

<TABLE>
<CFOUTPUT QUERY=&quot;Projects&quot;>
<TR>
<TD>#Project#</TD>
<TD><CFIF TargetDate IS &quot;1/1/9999&quot;>Target Date Not Yet Scheduled<CFELSE>#TargetDate#</CFIF></TD>
</TR>
</CFOUTPUT>
</TABLE>
[/tt]
You may want to try
[tt]SELECT Project,
ISNULL(TargetDate, &quot;Target Date Not Yet Scheduled&quot;) AS TargetDate
FROM titles
[/tt]
but I'm not sure whether you'll run into type mismatching or not. (It would make the CFOUTPUT simpler, though..:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top