Date Filter in SSRS 2008 - datetime

I am working with SSRS 2008. I have a table in my report consisting a date/Time Column (DOB). I have a date/time parameter (MyDate) as well. I am trying to set a Filter on my data set like
FormatDateTime(Fields!DOB.Value,2)<=FormatDateTime(Parameters!MyDate.Value,2)
It doesn't filter my table correctly. But if I remove FormatDateTime function then it works fine. i want to understand whats the problem here.

FormatDateTime will return a string, so you're not comparing dates anymore but rather their string representations.
Comparing the dates 02-Feb-2012 and 10-Oct-2012 will give different results than comparing the strings 2/2/2012 and 10/10/2012.
As mentioned in the comment, it looks like you're just trying to remove the time portion from dates?
Something like this should work, i.e. converting the strings back to dates.
CDate(FormatDateTime(Fields!DOB.Value,2)) <= CDate(FormatDateTime(Parameters!MyDate.Value,2))
But this is just one suggestion, there are any number of ways of doing this.

Related

Gather turns my dates into unrecognisable format

I am trying to gather a couple columns of dates so that its easier for it to be choices in shiny. However, when I gather dates, it turns into for example, 2020/12/14 to 128284 format. I have tried as.Date, as.character, I have tried lubridating but it doesn't work. (I have been gathering in a separate script besides shiny). Please see my code when gathering.
Here is my data
before gather
df<-df%>%gather(key="date.type", value="dates",
date.1, date.2, date.3, date.4)
This turns it to something like this;
after gather
This becomes a problem when I am trying to find difference between two dates in Shiny(I have been using difftime).
The error I get in shiny is:
x character string is not in a standard unambiguous format
I am also thinking of not gathering at all, but allowing the user to choose the from date column and to date column in the UI, but I am not sure how to then find the difference in days between the from and to dates in the server.
mutate(theduration=difftime(input$to,input$from,units="days")
This doesn't work.
OK, so I had this problem when using gather to make a dataset. When you get those 5 digit time character blocks, try this:
mutate(time=as.Date(as.numeric(time),origin="1899-12-30"))
Apparently, that that 5 digit number is days since the origin date. It's a MS thing. Good Luck!

Conditional formatting if a datetime value is present in a list of datetime values

I am trying to compare two lists of DateTime values in a Google Sheets. I want to highlight all DateTimes in the first list which are also present in the second list.
I already tried to use MATCH(), COUNTIF(), FILTER() together with COUNTA() or other approaches. However, although the values in both lists are basically copies of each other (just with some missing values in the second list), no matches will be returned. All are "true" DateTime values which can be formatted by using any of the date and time formatting options.
The MATCH example:
=ISNUMBER(MATCH(A2,INDIRECT("OTHERSHEET!$A$2:$A"),0))
I assume that there might be differences in the DateTime interpretation in the comparison why I also tried to use N() without success. I will always get an error like Did not find value '43297.75867' in MATCH evaluation. respectively FALSE after the ISNUMBER().
If I just do something like =N(A1)=N(OTHERSHEET!A1) with matching DateTimes, I get TRUE.
Same principle, but shorter:
=MATCH(A1,INDIRECT("OTHERSHEET!A:A"),0)
custom formula: =ISNUMBER(MATCH(A1,INDIRECT("OTHERSHEET!$A$1:$A"),0))

Convert time hh:mm:ss to decimal values (hours or minutes)

I am trying to create a chart using a SQL database, I am using the duration column(HH:mm:ss) and the People column(Names).
But ASP does not support Time values for charts .Is there any other approach to display a TIME value like "45:34:12" to a column chart?I am trying to achieve a result like the one below.
If it is not possible ,is it possible in SQL to convert all the column that contains the "HH:mm:ss" values to a new decimal hour's column ?
Use a number instead.
Like it could be 10.84 hours or 2567.5 minutes.
This should work, but is less beautiful than the HH:mm:ss format.

Using Dates in SQLite

I have a TEXT column called "time" in a table meal and in a table pain which is TEXT formatted as YYYY-MM-DDTHH:MM. I'm trying to search for other times that are within 12 hours of a given time, although I can't figure out how to do that.
I've tried testing
WHERE pain.time < meal.time + "1:00" AND pain.time > meal.time
but this approach alters the year instead of the hour. I also tried testing the same query adding "0000-00-00T01:00", but it doesn't seem to do anything.
I'm not sure what else to test.
SQLite has no built-in date/time data type, so you have to use either numbers or strings and handle them correctly.
To do calculations, you have to either do them directly on the numerical value (which might require conversions into a number and back), or use the modifiers of the built-in date/time functions:
... WHERE meal.time BETWEEN datetime(pain.time, '-12 hours') AND pain.time

Format string on dimenion attributes SSAS

I have a SSAS multidim cube (2012) and I am trying to set format for some dimension attribute (for example percentage - I would like to display 0.12 as 12%).
I have tried with both dot and coma as decimal
I have tried with data types decimal, float and varchar/nvarchar
I have tried setting both the format string and format properties (both together and one at a time)
I have tried other format strings than "Percentage", both the ones that are included in SSAS and custom ones (##.## etc.)
It works for measure but I cant get it to work for any dimension attributes (I got 0.12 instead of 12%).
I know that excel translates all dimension attributes to strings but I don't get this to work in SSMS either.
Do anyone know if this is a bug in SSAS?
I have found a couple of posts like this one: http://www.ssas-info.com/forum/6-ssas-admindevelopers-lounge/2196-format-option-not-working-for-attribute
An easy workaround would be to do the formatting via SQL in a named calculation in the DSV, or in a view which the DSV is accessing. Then you would use that column as the name column for your attribute.

Resources