Page 1 of 1

Calculated column using date column

Posted: Thu Oct 27, 2011 4:40 pm
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)

Calculated column using date column

Posted: Fri Oct 28, 2011 7:50 am
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.