Showing posts with label textbox. Show all posts
Showing posts with label textbox. Show all posts

Tuesday, March 20, 2012

Problem with Format() Function in expression

Hi,
I have a textbox with an expression to format integer data:
="HH: " + format(Fields!ANZHH.Value,"#.###.") + ", EW: " +
format(Fields!ANZEW.Value,"#.###.")
I want that integer values appear as: HH: 1.000, EW: 3.890
("." = group digit )
However the custom format style that I use does not return the expected
result, instead RS shows HH: 1000, EW: 3890
Any ideas how to troubleshoot?
--
Thanks in advance
BodoI finally got it solved:
1) modified expression to:
="HH: " + format(Fields!ANZHH.Value,"#,###.") + ", EW: " +
format(Fields!ANZEW.Value,"#,###.")
2) set report property Language to Default.
As a result values are formated in the culture specified in IE language
settings.
Bodo|||I'm guessing I'm not the first to ask this, but haven't found anything
either here or via googling around.
Per the subject, some of our database fields have html code in them that we
would like to render inside the report (using the table control) as actual
html instead of just code, is this at all possible with some toggles or
perhaps expression injection? Its mostly stuff like fonts colors/sizes/etc,
nothing drastic, but of course its showing up as a bunch of
<this><that>...etc rathern than actual html.
Please let me know either way, or perhaps point me to an example somewhere?
TIA.
andy|||Apologies for the above :(
"Andrzej E. Raczynski" <andy@.aea13.org> wrote in message
news:9CA7AD98-7309-4C21-B000-46E7CDFD429C@.microsoft.com...
> I'm guessing I'm not the first to ask this, but haven't found anything
> either here or via googling around.
> Per the subject, some of our database fields have html code in them that
> we would like to render inside the report (using the table control) as
> actual html instead of just code, is this at all possible with some
> toggles or perhaps expression injection? Its mostly stuff like fonts
> colors/sizes/etc, nothing drastic, but of course its showing up as a bunch
> of <this><that>...etc rathern than actual html.
> Please let me know either way, or perhaps point me to an example
> somewhere?
> TIA.
> andy

Saturday, February 25, 2012

Problem with datetime expression

I have the following expression in a textbox in a table based on a dataset:
=IIF(Fields!Opened.Value="No","No",Format(Fields!Opened.Value,"yyyy-MM-dd
HH:mm:ss"))
The result I recieve when there is supposed to be a date is the date
mask (yyyy-MM-dd HH:mm:ss) instead of the actual value of the date.
Any ideas?
Best regards,
Peter!On Dec 7, 7:17 am, Peter Larsson <scape...@.hotmail.com> wrote:
> I have the following expression in a textbox in a table based on a dataset:
> =IIF(Fields!Opened.Value="No","No",Format(Fields!Opened.Value,"yyyy-MM-dd
> HH:mm:ss"))
> The result I recieve when there is supposed to be a date is the date
> mask (yyyy-MM-dd HH:mm:ss) instead of the actual value of the date.
> Any ideas?
> Best regards,
> Peter!
I assume that Fields!Opened.Value is a string value (because you are
using it twice there) that either contains the text "No" or a Date.
Try wrapping the second Value in a CDate() function to force a
conversion to DateTime. If the Format command is fed a value that it
can't convert, it returns the formatting string, not the value.
= IIF( Fields!Opened.Value = "No", "No", Format( CDate(Fields!
Opened.Value), "yyyy-MM-dd HH:mm:ss") )
-- Scott|||Orne wrote:
> On Dec 7, 7:17 am, Peter Larsson <scape...@.hotmail.com> wrote:
>> I have the following expression in a textbox in a table based on a dataset:
>> =IIF(Fields!Opened.Value="No","No",Format(Fields!Opened.Value,"yyyy-MM-dd
>> HH:mm:ss"))
>> The result I recieve when there is supposed to be a date is the date
>> mask (yyyy-MM-dd HH:mm:ss) instead of the actual value of the date.
>> Any ideas?
>> Best regards,
>> Peter!
> I assume that Fields!Opened.Value is a string value (because you are
> using it twice there) that either contains the text "No" or a Date.
> Try wrapping the second Value in a CDate() function to force a
> conversion to DateTime. If the Format command is fed a value that it
> can't convert, it returns the formatting string, not the value.
> = IIF( Fields!Opened.Value = "No", "No", Format( CDate(Fields!
> Opened.Value), "yyyy-MM-dd HH:mm:ss") )
> -- Scott
Hi Scott!
Thanks for the tip, now the date works but I get the #Error on the When
the value contains "No".
/Peter|||On Dec 7, 11:05 am, Peter Larsson <scape...@.hotmail.com> wrote:
> Orne wrote:
> > On Dec 7, 7:17 am, Peter Larsson <scape...@.hotmail.com> wrote:
> >> I have the following expression in a textbox in a table based on a dataset:
> >> =IIF(Fields!Opened.Value="No","No",Format(Fields!Opened.Value,"yyyy-MM-dd
> >> HH:mm:ss"))
> >> The result I recieve when there is supposed to be a date is the date
> >> mask (yyyy-MM-dd HH:mm:ss) instead of the actual value of the date.
> >> Any ideas?
> >> Best regards,
> >> Peter!
> > I assume that Fields!Opened.Value is a string value (because you are
> > using it twice there) that either contains the text "No" or a Date.
> > Try wrapping the second Value in a CDate() function to force a
> > conversion to DateTime. If the Format command is fed a value that it
> > can't convert, it returns the formatting string, not the value.
> > = IIF( Fields!Opened.Value = "No", "No", Format( CDate(Fields!
> > Opened.Value), "yyyy-MM-dd HH:mm:ss") )
> > -- Scott
> Hi Scott!
> Thanks for the tip, now the date works but I get the #Error on the When
> the value contains "No".
> /Peter- Hide quoted text -
> - Show quoted text -
Ok, just made some test data. I think that the second half of the IIF
statement is still being evaluated, and for those rows where the value
is "No", the CDate is failing, therefore the whole IIF is failing.
So, before we do the CDate, we have to check again if the value is a
non-convertable date, then if it is not convertable, set it to
Nothing. CDate(Nothing) is still Nothing, so then the second half of
the IIF would succeed.
The following works the way I think you want it to:
=IIF( Fields!Opened.Value = "No", "No", Format( CDate( IIF(Fields!
Opened.Value = "No", Nothing, Fields!Opened.Value) ), "yyyy-MM-dd
HH:mm:ss" ) )
-- Scott