Wednesday, March 7, 2012

Issue with FORMAT use in textboxes when null value

SQL 2005 Dev, VS 2005

I use the following in my VS-created reports:

FORMAT("ShortDate", Fields!someField.value)

However, when the field returns a null field what displays in the tex box instead is the words "ShortDate". Can this be corrected?

Thanks in advance

Please reverse the order of the arguments, and use DateTime format strings as shown in the MSDN documentation:

* Standard datetime formats:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandarddatetimeformatstrings.asp

* Custom datetime formats:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconstandarddatetimeformatstrings.asp

In your case, you should try e.g. =Format(Fields!someField.Value, "d")

Alternatively, you can set the textbox Value property to =Fields!someValue.Value and set the Format property of the textbox to the desired format code.

-- Robert

No comments:

Post a Comment