Why is the output for my datediff expression to return a number of days bracketed? - sql

I have written the following expression to give me the number of days between a date and today.
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,datediff("d",Today,Fields!First_Check_Start_Date.Value))
The output is correct but is bracketing the number
ie. (292) instead of 292
Any help as to why this is

if you are using text box to display your result, check what is the type of your text box. Make it as number and look for it's format and set to correct
Else you could also format like below
=IIF(Fields!First_Check_Start_Date.Value = nothing,nothing,Format(datediff("d",Today,Fields!First_Check_Start_Date.Value),"##"))

So it appears that whilst viewing in SSRS Report builder the numbers are bracketed (292), however once export to either csv or excel the bracket disappears and is replaced bi a minus -292 which is correct
Thanks

Related

Adjusting number format using vb.net

I have this statement nested in an IF-Statement under a scenario. I would like it to format column 2 into a Accounting number without decimal places. How can this be done using VB.net? The current code gives me ex: 1,000,000.00 on an input of 1000000. I noticed excel has buttons for adding or subtracting decimal places. Could these be called within VB.net? Thanks!
Lo.ListColumns("Column2").DataBodyRange(CurrentRow).NumberFormat = "ACCOUNTING"
Try the following
Lo.ListColumns("Column2").DataBodyRange(CurrentRow).NumberFormat = "#0,000.00"
You may find help in this Article
From what i understand you want, you can do:
math.floor(*insert the value or variable you want here*)
What that does is it changes the number in the parameter to the biggest integer lower than the parameter.
Hope this works :)

SSRS export timespans more 24 hours to excel

friends.
I have field in my report that contains time string 25:00:00. How can i export this field to excel and get column format [h]:mm:ss automatically?
Steps that i tried:
Used function System.TimeSpan.FromSeconds(90000). But it gave me result 1.01:00:00 and it exports to excel as General format.
Used expression for TextBox properties -> Number in SSRS like this:
=IIF(Globals!RenderFormat.Name="EXCELOPENXML","[h]:mm:ss","HH:mm"). It gave the same result as previous.
If there are some ideas how to decide this problem, I wait your suggestions. Thanks.
FORMAT function removes the actual data type of the column while exporting. So Instead i will suggest use FORMAT property (as in below screenshot)
Now if you try again & export report to excel it will export using the format property of that cell.

Format Text to Number format in Report Builder 3.0

I am working with 4 fields in Report Builder 3.0 in which I am trying to format as a number with the corresponding comma. When I use the number format in the Text Box Properties nothing happens. When I export this report to Excel the field has to be converted to a number as it is being exported as a text field.
Do you have any suggestions as to how I can change the formatting in the report itself?
Thanks for your time!
If I pull data from Oracle using an openquery I get the same issue. To resolve:
When you have the Text Box Properties box open, select the function key by the Value.
In the expression, add "Int" at the front of the string with () on each side of expression. (This converts the value of the expression to an integer)
Ex: =Int(Fields!Count.Value)
Close the expression box after making these additions and select "Numbering" in Text Box Properties to format the text box accordingly.

Detecting NULL dates and showing empty string in SSRS

I'm trying to format some cells in a Reporting Services report that will contain DateTime? values - or not.
If the underlying data has a NULL for that DateTime?, I'd like to show nothing (empty cell) - and if that data source contains a value, I'd like to show the date in short date format (dd.MM.yyyy in my locale).
So I tried to put this formula into the relevant SSRS cells
=FormatDateTime(Fields!DatumBSE.Value, 2)
but now I'm getting 01.01.0001 for all NULL dates....
I can't seem to wrap my head around how to do this in a SSRS (VB) formula.... I tried using IsNothing() but that doesn't seems to really help - I can detect a NULL, but how to I tell the cell to show an empty string in that case?
Solution:
I ended up using this function:
=IIF(IsNothing(Fields!DatumBSE.Value), "", FormatDateTime(Fields!DatumBSE.Value, 2))
Seems to work just fine for me now.
I just tested the following expression and it replaced the null date with an empty string:
=IIF(Fields!DatumBSE.Value is nothing, nothing, FormatDateTime(Fields!DatumBSE.Value, 2))
The other suggestion that I would make is that you could format the date to the correct format in the report dataset by placing a CASE expression around the date value.
use a code like this:
If(isNull([date field]),Null, elsequote)

Custom Number Format in Crystal Report !

How can i format quantity value in crystal report like if the value is 5, then just show as 5. If the value is 5.25, then show as 5.25. So which format should i use for that?
Thanks.
Right-click on the element and go into the formatting menu. I think what you want will be an option.
Instead of displaying it as a numeric value, write a function, MyStr$, which converts to string depending on whether the number is integer or not. BTW, a good way to check for integrality is a test of the form:
ABS(x -Truncate(x)) < EPS
where EPS is a small value, like 0.001 (depending on the accuracy you need, increase or decrease this)
Use this "conditional format formula":
If Truncate(CurrentFieldValue) = CurrentFieldValue
Then
0
Else
Length(ToText(ToNumber(StrReverse(ToText(Abs(CurrentFieldValue) - Truncate(Abs(CurrentFieldValue)),8,"",""))) / 10,0,""))
Go to the numeric report field, rightclick, choose "Format Field", choose "Number" tab, click "Customize" button. Put the formula above in the format formula ("X+2" button) for the format options "Decimals" and "Rounding".
BTW: In the formula you'll notice the number 8. This is the maximum expected number of decimals; if you think you'll encounter more decimals in your report then simply change 8 to a higher number.