Calculated column using date column

Stimulsoft Reports.WEB discussion
Post Reply
jay@bplogix.com
Posts: 251
Joined: Fri Feb 04, 2011 11:46 am
Location: San Diego, CA

Calculated column using date column

Post by jay@bplogix.com »

I have a date column "dt" that can accept nulls. I want to create a calculated bool column that returns true if the date is less than today, or false otherwise.
The formula is:
(MyTable.dt < DateTime.Now)?true:false

This almost works ... but of the date value is a NULL, then the formula returns a null as well. What is the easiest way to write a formula for this ... I could manually check for a null but that makes the formula really complex:
(IsNull(MyTable,"dt2))?true:((MyTable.dt < DateTime.Now)?true:false)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Calculated column using date column

Post by HighAley »

Hello.
[quote="jay"@bplogix.com]I have a date column "dt" that can accept nulls. I want to create a calculated bool column that returns true if the date is less than today, or false otherwise.
The formula is:
(MyTable.dt < DateTime.Now)?true:false

This almost works ... but of the date value is a NULL, then the formula returns a null as well. What is the easiest way to write a formula for this ... I could manually check for a null but that makes the formula really complex:
(IsNull(MyTable,"dt2))?true:((MyTable.dt < DateTime.Now)?true:false)
[/quote]
Please, try to use next expression

Code: Select all

(MyTable.dt < DateTime.Now || IsNull(MyTable,"dt"))?true:false
Thank you.
Post Reply