drupal views difference between two dates - date

I want to create a view in which there are two fields start date and end date. I want to display one more field that is (difference between the start date and end date).
All this three fields should be displayed in table format.
So please tell me how to find difference between two dates using views?And i want to display this difference between the date fields as third column of the table.

You can try with Computed Fields. It allows you to define a new dynamic field for any content type (stored in database or computed on the fly), and you can code in PHP the value for this field, using other fields values.
Creating a computed field to store two dates fields difference is one of the example in the module doc :
https://www.drupal.org/node/149234
Then in your view you just have to display the computed field (and the two original fields).
Views PHP can do the trick as well, it allows you to create a new field within a view, which will be computed in PHP. You can use other fields values to calculate its value.
But I would recommend Computed Fields, Views PHP can be a performance killer.
Good luck

Related

Query date range for date saved in a text field in IBM Notes and Domino

There is a date saved in a text field. I'm trying to get documents collection when the field is in a date range using db.FTSearch method. But > and < doesn't work in a text field. Are there any way to convert text field? I'm not familiar with IBM Domino and have tried #TextToTime but doesn't work.
A few ways:
use db.Search instead of db.FTSearch; the syntax is completely different though, plus it is rather slow, but if you have to execute your query once per day or even less, you're fine
write an agent that converts the text date fields into new real date fields, so you can do your FTSearch; make sure you adapt the form used to create the documents, so that it also creates those date fields
use a view, where the first 2 columns contain the date value of your text fields, and sort the view; you'd have to use getDocumentByKey (but I'm not sure this works)
Your date is stored as text, so you need to use #TextToTime().
I.e.,
FIELD #TextToTime(field1) >= [01/01/2018] AND
FIELD #TextToTime(field1) <= [01/19/2018]

Show data based on selected date - QlikView

I have a list box of dates and a table which has datetime as dimension. The dates from list box is a separate table from that with complete date. I tried connecting them by cutting the datetime into just date (another field) in my select script but did not work. So I thought this should be done on the conditional of datetime dimension but I'm not sure how to do this. How should I be able to show data based on selected dates in Filters?
I would recomend two different approaches, recomending the first one :
On the LOAD script, along side loading the DateTime field, loading the same field again with only the Date part and use than one for filtering. Something like :
LOAD
<... some fields ...>
DateTimeField,
Date(Floor(DateTimeField)) as DateTimeFieldFilter
<... some more fields...>
Add a field selector for you DateTime field, then to Properties, Field dropdown and choose the last option "Expression". On the Expression box enter Date(Floor(DateTimeField)).

Tableau - Filter/Parameter For Different Date Ranges

I am trying to set up a filter or parameter for different date ranges in Tableau, such as:
Previous Week
Previous 4-Weeks
Previous 8-Weeks
based on the most recent data in the database. Is this possible?
Edit:
I should have been more clear here.
Is it possible to only have these options in the filter and have it based on the maximum date in the database?
Update
Based on your comment and updated question, you can do it as you intend, though it isn't as straight-forward.
NOTE: I did this very quickly and with a random data set, so it will be important for you to test this thoroughly with your data set.
Steps:
Create a parameter control that the users will use to change the selected date range. I created this as a list of strings with values that I can use directly in a calculated (after simple casting):
Create a calculated field that you will use as a filter that references the selection of the parameter control. It tests to see if the difference (in weeks) between the maximum date in the view and the date of any given row is less than the value of the parameter.
Calculation: INT([Date Filter Parameter]) > DATEDIFF("week",ATTR([Date Field]),WINDOW_MAX(MAX([Date Field])))
Place the calculated field in the filter box and set it to True.
You will be able to filter your data like so:
Original Answer
Yup - that is built into Tableau.
Add your date to the filter and select the "Relative Date" option:
You can set the defaults - users can change these later:
Then just "Show Filter":

How to merge two data sets in Tableau via relationship?

I'd like to create a combination bar/line chart and combine two data sets. I'd like the columns to be months and the rows to be the aggregate values within those months. However, I'd like one of the data sets to display as a bar chart and the other data set to display as a line chart. It should look like this:
I have the following data sets:
data_set1 = [{'value':10,'date':2016-01-01},{'value':15,'date':2016-01-02},{'value':5,'date':2016-01-03},{'value':10,'date':2016-01-04},{'value':120,'date':2016-02-01}]
data_set2 = [{'value':100,'date':2016-01-01},{'value':200,'date':2016-02-01}]
I've been able to create the bar chart (see below):
However when I try to add the values from the second data set by also adding it to the columns section, I get the following error:
"In order to use fields from dataset 2, a relationship needs to be created with dataset 1. Select Data > Edit Relationships to open the Relationships dialog box."
I tried to create a relationship between these two data sets by the following process:
Set the Primary Data Source as data_set2, since that is the smaller dataset.
Selected Custom to create a custom relationship
Selected Add and set both the 'Primary Data Source Field' and the 'Secondary Data Source Field' as Date
However,
When defining the relationship between two date type fields, try selecting the level of aggregation for the date fields, such as Month(Close_Date) in source 1 maps to Month(Date) in source 2. In effect, every value in those fields is first truncated to the beginning of the period (month in this case) before comparisons are made.

SSAS Date Field in None Date Dimension

I have issue trying to filter in excel 2010 pivot table on date attributes from a Cube source.
My problem is i have Date attributes in NONE date dimensions my example is a Asset Dimension that has a set of date attributes like:
Bought date
Sold Date
Repair Date
Is there a way to set these attributes to type date so pivot table will directly identify them and allow use of Date Filters ?
Or do i have to create a Date dimension for each attribute and user will have to select which Dimension he wants to slice data by
One option is to add an additional date "role-playing" dimension to the cube (e.g. DimAssetBoughtDate) and hang it off the fact tables using a reference-relationship through the Asset dimension. This not only provides you with the date-based filtering but also all of the built in hierarchies. Plus date dims are usually pretty small so materializing the relationship shouldn't be an issue.
Note: you may need to add a calculated member to your Asset dimension in your DSV to convert the date value (e.g. AssetBoughtDate 3/12/2015) to the date-key value (e.g. AssetBoughtDateKey 20150312) in order to properly add the new DimAssetBoughtDate.