Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
How to handle NULL date
maximoadmin
<p>[color=#000080;][font="georgia, serif;"]Hi All,[/color][/font]</p><p> </p><p> </p><p>[color=#000080;][font="georgia, serif;"]If there is null value in database for a particulat field we can display text "N/A" in report instead of null for String data types as below.[/color][/font]</p><p> </p><p>[color=#000080;][font="georgia, serif;"]datasetrow[attributename] || "N/A"[/color][/font]</p><p> </p><p> </p><p>[color=#000080;][font="georgia, serif;"]But how can we display string "N/A" for Date data types if there is NULL value in database for date filed?[/color][/font]</p><p>[color=#000080;][font="georgia, serif;"]Any help...................
[/color][/font]</p><p> </p><p> </p><p> </p><p>[color=#000080;][font="georgia, serif;"]Thanks.[/color][/font]</p>
Find more posts tagged with
Comments
wwilliams
<p>if Sql Server try isnull(convert(varchar,targstartdate,1),'N/A') or coalesce(convert(varchar,targstartdate,1),'N/A')</p>
maximoadmin
<p>Hi Williams,</p><p> </p><p> Thank's for your quick reply...We don't want to change the sql query.......We want to change the out put only in report page</p><p> </p><p> I did this adding java script in Expression builder,Issue resolved. below is the script.</p><p> </p><p><strong class='bbc'>if</strong>(dataSetRow["extdate"] == <strong class='bbc'>null</strong>)</p><p>{</p><p><strong class='bbc'>var</strong> a=String(dataSetRow["extdate"]);</p><p>a='N/A';</p><p>}</p><p><strong class='bbc'>else</strong></p><p>{</p><p>dataSetRow["extdate"]</p><p>}</p><p> </p><p> </p><p> </p><p>Thanks..</p>
micajblock
<p>But then it is no longer a date (so it is not easily formatted). You are better of putting this script in the onRender</p><p> </p><div><pre class="_prettyXprint">if (this.getValue() == null) {this.setDisplayValue("N/A");}</pre></div>
vijayshankar245
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="121018" data-time="1381079828">
<div>
<p> </p>
<p>But then it is no longer a date (so it is not easily formatted). You are better of putting this script in the onRender</p>
<p> </p>
<div>
<pre class="_prettyXprint">
if (this.getValue() == null) {this.setDisplayValue("N/A");}</pre>
</div>
<p> </p>
</div>
</blockquote>
<p>Hi</p>
<p> </p>
<p> I have to handle a date value '3499-01-01' in my report, So i wrote something as below, It doesnt work. Please help</p>
<p> </p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><strong>if</strong>(dataSetRow["vdate"] == <strong>'3499-01-01'</strong>)</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">{</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><strong>var</strong> a=String(dataSetRow["vdate"]);</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">a='N/A';</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">}</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;"><strong>else</strong></p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">{</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">dataSetRow["vdate"]</p>
<p style="color:rgb(40,40,40);font-family:'Source Sans Pro', sans-serif;">}</p>
micajblock
<div>'3499-01-01' is a string not a date. So if vdate is of date data type your code should look like this. Again as a rule I would discourage against changed the date to N/A, just what is displayed. So similar to above I would put the following code in the onRender event:</div>
<div>
<pre class="_prettyXprint">
if (this.getValue() == new Date(3499,1,1)) {this.setDisplayValue("N/A");}</pre>
</div>
<div>However if you still want to create a data item with an expression it needs to be of type string (not date) and the expression should be:</div>
<div>
<pre class="_prettyXprint">
if(dataSetRow["vdate"] == new Date(3499,1,1)){
"N/A";
}
else {
Formatter.format(dataSetRow["vdate"],"yyyy-MM=dd");
}</pre>
</div>
<div>P.S. You can format the date anyway you want.</div>
vijayshankar245
<blockquote class="ipsBlockquote" data-author="mblock" data-cid="144752" data-time="1469732115">
<div>
<p> </p>
<div>'3499-01-01' is a string not a date. So if vdate is of date data type your code should look like this. Again as a rule I would discourage against changed the date to N/A, just what is displayed. So similar to above I would put the following code in the onRender event:</div>
<div>
<pre class="_prettyXprint">
if (this.getValue() == new Date(3499,1,1)) {this.setDisplayValue("N/A");}</pre>
</div>
<div>However if you still want to create a data item with an expression it needs to be of type string (not date) and the expression should be:</div>
<div>
<pre class="_prettyXprint">
if(dataSetRow["vdate"] == new Date(3499,1,1)){
"N/A";
}
else {
Formatter.format(dataSetRow["vdate"],"yyyy-MM=dd");
}</pre>
</div>
<div>P.S. You can format the date anyway you want.</div>
<p> </p>
</div>
</blockquote>
<p>Thanks </p>