For one of my Matrix reports, the column headers are Dates which I am trying to format in the form of 'Mon 07' i.e. short date name followed by date value.
For this I am using the expression - =Format(CDate(Fields!WorkedOnDate.Value),"ddd")
I then wanted to trim the right 3 letters.
I am getting weird output.
Here is what I am getting for one week-
Tue, We2, T12u,ri,SaA,Sun,7on
Any idea what is going wrong?
This was asked in this link but that answer didn't help -
The date formats do not seem to work in SSRS
I realize my mistake now. I was adding the Format property across Number-> Format property of that textbox. I solved this by adding as part of the textbox Property value.
Related
In my SSRS report i have a date parameter and i want to set to it a default value with a complicated logic. I arrived at this strange behaviour:
Today is May 6th, wednesday. If i use the following expression:
DateAdd("d",Weekday(Today(),DayOfWeek.Sunday),Today())
for the default time picker I get May 9th.
If I use exactly the same expression in a textbox in the same report
DateAdd("d",Weekday(Today(),DayOfWeek.Sunday),Today()).ToLongDateString()
I get May 10th!
The only thing that changes is the toString.
Why are the two values different?
I tried with different expressions and the difference arises when i start using Weekday(Today(), somevalue)
After a while and some fundamental help i realized that I had to use "FirstDayOfWeek" instead of "DayOfWeek" in both expressions for both of them to be the same regardless of current culture.
i'm trying to specify dd/mm/yyyy dateformat for date/time parameter in SSRS 2008 R2.
My computers datetime format is mm-dd-yyyy.
My requirement is, i want to show date format at dd/mm/yyyy irrespective of the system/server date format.
I've already tried CDate(Format(Today,"dd/mm/yyyy")) which didn't work. one very strange thing i observed is, it shows dd/mm/yyyy format only for dates on or before 12-MM-yyyy, and 13 onwards it gives error: Conversion from string '25-04-2014' to type Date is not valid. (Possibly it is trying to map 25(daypart) with MM-dd-yyyy (month part)) which is out of range of total months i.e. 12)
my research on internet says it is a bug in BIDS 2008.
What do i do to display date as dd/mm/yyyy ??
I don't have enough reputation to comment, but I did notice that you failed to put "()" after "Today". If I'm not mistaken you must put Today() for that function to work. Also, you might want to try putting CDate Around the Today() function. You shouldn't need it, but it's worth a shot. Also, for some odd reason, in my experience, you must capitalize MM for format to work correctly.
Like #Aditaya said, it should be =format(Today(),"dd/MM/yyyy")
The expression I usually use is:
=FormatDateTime(Fields!Date.Value, DateFormat.ShortDate)
However, this may be region specific.
Rather than writing an expression to do the formatting, you can also use the Textbox Format Property. But first you need to make sure that the data is in a date format. So use the CDate function on your column like this:
=CDate(Fields!Date.Value)
Then in the textbox properties go to the Number tab. Select Date for the category. Then you can select whichever format you want or use a Custom format. This will change how the column displays when you run the report.
I have an ssrs chat, I want to bind time valeus to y axis.
Data comes in "2013-11-21 16:07:31.000" format
I need 16:07 value as time. but no function give me that.
when I use cdate, and then Format it does not work . HHmm returns me an inteeger 1607 bur HH:mm doesnt work.
please help I am about to go crazy!
Try leaving your value, or setting up a calculated field that just uses =CDate(Fields!AverageTime.Value) or =DateTime.Parse(Fields!AverageTime.Value)
Then, I assume you use that date field as a category on your graph. Set the format on the X axis to HH:mm as shown below. Let the graph handle the display using format strings, don't use the Format function.
I am having a few issues using SSRS-Reports 2005.
The first one is I am trying to use the datediff function to change the background color of a cell based on the two dates being within 30 days of each other.
=iif(
DateDiff("d",DateString,Fields!Insurance_Certificate.Value)<= 30, "Tan", "White"
)
I have my fields formatted through the initial query so they look like mm/dd/yyyy. I guess my first question is how do I see what value is being evaluated because whatever this is returning can't be right.
my [...] question is how do I see what value is being evaluated
There is no real "debugger" available like you would have in -say- a WinForms C# app. Instead, you have several "raw" "debugging" options:
Render Fields!Insureance_Certificate.Value in a seperate cell, as text
Render DateDiff("d",DateString,Fields!Insurance_Certificate.Value) in a seperate cell, as text
Right-click your dataset, select "Query...", and execute the query manually. Inspect the values for your field. Make sure they're what you'd expect.
Render your DateString in a seperate cell, with and without a cast to a date.
Other than that #MarkBannister has a great suggestion, using actual Dates as opposed to strings for your fields and variables. One additional thing to note about this, is that date parsing may be culture-specific. Be sure you understand and know in what culture your DateString is being parsed. The above "debugging" options may help you find out.
I suggest querying your date fields as dates (instead of as strings), comparing them using the DateDiff function as in the question and formatting the date output using the Format property of the appropriate textboxes in SSRS.
I have a report and a datasource where one of the columns are of type TimeSpan. The TimeSpan value appears to display correctly in the report when I use Fields!TheTime.Value, no problem there.
07:02:00
05:41:00
But I would like to do a Sum on those values to get the total time of a group. In C# and such I can of course do a TimeSpan + another TimeSpan, so I know they can be added. I tried
=Sum(Fields!TheTime.Value)
But it ends up printing out as a long number of some sort. For example for the outputted times above, I would get 457800000000 as the sum. And what is that even supposed to be?
Anyways, how can I sum timespan values in a report? For the above timespans I would like to end up with 12:43:00 as the sum. Unless my head failed me at math once again... but you get the idea :p
sigh The solution annoyingly simple... Why couldn't I just have tried that in the first place? Oh well... maybe because I didn't realise I had access to TimeSpan class... maybe because I had thought myself blind... But anyways, here it is:
=TimeSpan.FromTicks(Sum(Fields!TheTime.Value))
D'oh!
#Svish - I deleted my previous post because I had a fit uncertainty about my answer but I concur with #pfunk.
I finally got SSRS back up and had a play around and it certainly looks like your big number is the number of ticks so it looks like a bit of formatting of the result will work for you.
Interestingly enough my previous convoluted answer was a workaround for summing DateTime values (using SQL Server DATETIME datatype in my query) which you cannot do in SSRS (and SQL) because you cant sum a DATETIME. I'll include it here again for future reference but I think was on a bit of a tangent earlier :)
The below code converts a DateTime field into a double, sums the result and then converts it back to DateTime and formats it for hh:mm:ss
=Date.FromOADate(Sum(Fields!TheTime.Value.ToOADate())).ToString("hh:mm:ss")
What is probably happening is that when you display Fields!TheTime.Value, SSRS is smart enough to know to display that as a DateTime type field
when you add the sum in there it thinks it is a numeric type field and displays it as such (ie, it is summing the number of "ticks" in each timespan field)
try specifically formatting the summed value as a datetime in the field properties and it will probably show correctly