Grafana dashboard: automatically set a date variable to the current date - grafana

I have a Grafana dashboard with a date variable.
I always update the possible values once a day via a job to always be [currentDate - 2, currentDate - 1, currentDate, currentDate + 1, currentDate + 2] (I update the data source through the job). Sometimes the values can also differ, but the current date is always in there.
Now my users complained that the default value of that variable is always the first one, which is not always the current date. They want the default value to always be the current date (based on a predefined timezone).
I know that I can update this manually every day. Go into the dashboard, update the date and save. I do not want to do this. I want to update this automatically.
What way is there to do this? Does Grafana offer some native functionality with which to do it? Or do I have to do this with an external job or through some other means?

Make currentDate first in that variable list (yes, users may complain that it isn't in the logical order, but you can't have everything - unless you don't want to code own Grafana) and never Save current variables -> Grafana will preselect first value from the variable list in this case.
If you already have some saved current variables, then you need to edit dashboard model manually (export dashboard json/edit json - variable definition/import dashboard json).

Related

How to default variable (list of dates) to current date?

For some dashboards we have a date variable to pick a date from a list of dates. The dates are queried from an elasticsearch datasource.
In our case it would be great if we could somehow set the default value to the current date.
We are using Grafana 7.1.1. I am not sure if it can be achieved at all - Currently I am thinking about extending the elasticsearch-query to put the current date on top but I don't think Grafana can set the default value based on the index.
Another idea is to use a "global" date variable for the current date which I can search for in the variable selection field and then save the dashhboard.
Any hints (including feasibility) are appreciated.
Correct, make current date first in that variable list and never Save current variables -> Grafana will preselect first value from the variable list in this case.
If you already have some saved current variables, then you need to edit dashboard model manually (export dashboard json/edit json - variable definition/import dashboard json).

Tableau Dashboard Default set to Yesterday by using Date Parameter

I have created daily dashboard which shows the data for single date selected from DATE PARAMETER (with ALL value). Which is OK for me that I can see the data for any date I want.
But the problem is when I open my dashboard it is showing data for date which I selected in date parameter while publishing the Dashboard to Server/Online and Instead of that I want set it default to Yesterday.
i.e. when I open my dashboard first time it should show yesterday's data and also there should option to change date as well to see another date data.
Can we achieve this using DATE PARAMETER (with ALL values)? If it is not possible then is there any other way?
Please Help!
Use a relative date filter instead of a parameter. Just be sure to save and publish the workbook with Yesterday as the relative date value.
1, Create a calculation field d_yesterday, formula is TODAY()-1
2, Create a parameter, data type is Date, value when workbook opens set to d_yesterday
3, use the Date parameter in other calculations fields, or insert parameter into custom SQL query.

SSRS Preset or Custom Date Selection on Report

I currently have a report with the ability to select a start and end date. I was curious if you could make have both preset and the option for a custom selection
Selection:
Current Week, or
Previous Week, or
Custom Date Range.
Thanks,
Take a look at cascading parameters.
The link above seems to focus more on getting your cascading parameter values from a query, but you probably don't want that for a date - as far as I am aware, setting Available Values for a date parameter limits you to a dropdown list of dates, instead of the calendar which is generally easier to use. It is still a good background on how cascading parameters work though.
To do this with expressions for the default start/end date, you would basically want the first parameter to be a choice between "Current Week", "Previous Week", and "Custom Date Range". You would display those labels to the user, but the values can be whatever you want - for my test I just used 1, 2, and 3.
Then, you would set up 2 more parameters, one for the start date and one for the end date. Make sure the data type is Date. You will want to set up default values for these based on the value of the first parameter. I would do this with an expression such as the expression below for the start date. You also may need to modify this a bit depending on how you define the week - is the "Current Week" just the previous 7 days, or is it the latest Monday through today, or something else, etc.
=Switch(
Parameters!FirstParam.Value = 1, DateAdd("d", -7, Today()),
Parameters!FirstParam.Value = 2, DateAdd("d", -14, Today())
)
In this case, you don't even need to account for the 3rd option, because if the user wants a custom date range then you do not want the start and end date to fill in with any default values. You would need a similar expression for the default end date as well.
Since you want the user to be able to enter a custom range as well if they were to select the third option, you do not want to fill in the Available Values for the start/end date parameters, as the user would then not be able to select any date (at least as far as I am aware - if there is a workaround to that, I would love to see it, as that would be something I would like to use myself).
A possible downside to this approach is that if the user begins by selecting Current Week and then changes their mind to Previous Week, the start/end dates will not change to the Previous Week. You can read more about why this happens here, but essentially: since the values that are already filled in after selecting Current Week are still valid (they are dates, which is the only criteria for those parameters since no available values are set up), they will not refresh after changing the selection. The fix for this is to define the Available Values, but as mentioned above, this will then stop the user from entering a custom date range.

Oracle apex dynamic date time picker plugin minimum and maximum date

I have added a dynamic date time picker plugin to my oracle apex application. I want to set maximum date to this date picker. current date(or sysdate ) is the maximum date I want to set, the dates after current date should not be available for selection in the date picker.In the default apex date picker I add
+0d
in the maximum date field to set maximum date to current date. But this does not works with dynamic date time picker plugin.Plugin link : Apex dynamic date picker plugin link. How can I do this?
I wanted the same thing and managed to do it today. Here's my solution.
Create a dynamic action in the first Datepicker Calendar with the Change event.
Create the true action "Execute Javascript Code" and use the following code:
$('#P1_SECOND_CALENDAR').datepicker("option","minDate",$("#P1_FIRST_CALENDAR").val());
This function should make the second calendar set its minimum date to the one you've chosen on the first one, and it should happen when you pick it. Previous days should be greyed out on the second calendar once you open it to pick the second date.
Just replace the variables I used for calendars for the ones you have and it should work.
Checking the variables here again, I didn't choose a minimum date on the second Datepicker and APEX automatically chose a "+0d" value for it. It shouldn't be a problem. Try following these steps and see if it works.

SharePoint 2010: How can I pre-fill Scheduling Start and End Date?

I would like to know how to pre-fill the Scheduling Start and End Date in the metadata/properties of each item edited or created in a SharePoint list.
Scheduling Start Date: Today's date.
Scheduling Start Date: Today's date + one year.
Reason for ask: I configured the list items to expire and move into "draft" status when they hit their specified Scheduling End date, therefore un-publishing the item from external view.
Problem: Users/contributors are creating these items and are not entering enough time for it expire. What I'd like to do is automatically pre-fill the scheduling end dates for one year out from today's date when an item is edited or created.
Background info: I've enabled scheduling of items in a list (via "Enabling scheduling of items in this list" option in "Manage item scheduling" in Library Settings). I currently have a workflow and versioning enabled so that the admins check the content before it's view-able externally.
Your thoughts are appreciated.
This is pretty easy using Calculated Field Formulas in the default value fields of your two columns. Here and here are discussions on the basics of setting a default value for a date field, but it's pretty straightforward.
For Scheduling Start Date, set the default value to Today's Date. For Scheduling End Date, use the calculated value of =DATE(YEAR(Today)+1,MONTH(Today),DAY(Today)) for the default value.