Sue Taylor
asked on
SQL Expression help
I need help with creating an expression that will change the font color and make it bold based on if the field is less than today's date. I am using Visual Studio 2012. I have a datetime field that I only want to filter on the date.
The last expression I attempted was =iif(Fields!estimated_date .Value < GetDate(), 'Red', 'Black' I get an error GetDate is not delcared.
The last expression I attempted was =iif(Fields!estimated_date
Mark mentioned it correct..
GETDATE() is only at T-SQL level, if its from Visual studio then use DateTime.Now instead of GETDATE() to get it work..
If it is SSRS, then TODAY() can help..
GETDATE() is only at T-SQL level, if its from Visual studio then use DateTime.Now instead of GETDATE() to get it work..
If it is SSRS, then TODAY() can help..
This looks like VB used in reports, thus:
=IIf(Fields!estimated_date.Value < Date(), 'Red', 'Black')
' or:
=IIf(DateDiff('d', Fields!estimated_date.Value, Date()) > 0, 'Red', 'Black')
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi ITworks,
Kindly post your workaround and accept that as a solution instead of the above statement so that it might be helpful for others later on..
Kindly post your workaround and accept that as a solution instead of the above statement so that it might be helpful for others later on..
ASKER
I created a calculated field: =iif(Fields!estimated_date .Value < Today(), "1", "0") then I was able to use an expression to change the font color if it equaled "1"
>> " I get an error GetDate is not delcared."
Suggested using Today()
(depending on where / what app environment you were using)
Solution now uses Today()
And yet no one was recognised as assisting you..... Interesting.
Suggested using Today()
(depending on where / what app environment you were using)
Solution now uses Today()
And yet no one was recognised as assisting you..... Interesting.
Think you are barking up the wrong tree.
As a query, you cannot change a font like that, but as a report (SSRS), or an (say) ASP.NET output / web page, you can.
So what language/package are you using ?
For example, in SSRS you would be inclined to use Today() not getdate()
Or check DateTime.Now
And [yourobject].ForeColor = Color.Red
Using T-SQL, you wont be able to change the display property - you are past that point, and, needing your presentation tool to do that work