Forum Discussion

Archana's avatar
5 years ago

How to display the date?


I would like to know how to display the date and number of days between two dates.
For an example, I want to display today's date or current timestamp. Is there any possibility, that we can use any function (as like "getdate()" in SQL) to fetch the date/timestamp in any of the Widgets?
Also I want to know how to calculate and display the number of days between any particular dates.

Please help me on this.


2 Replies

Replies have been turned off for this discussion
  • You can embed javascript in the Text Widget. Add Text Widget > Source button and enter in something like this:

    <p id="today">[today]</p>
    var d = new Date();
    var date = d.getFullYear() + "/" + d.getMonth() + "/" + d.getDate()
    document.getElementById('today').innerHTML = date;

    Note that the javascript needs to be after the html code it modifies. I don't think you can use this javascript to modify other parts of the dashboard or extract data from monitoring because it's all contained inside an iframe. I also don't know if this will continue to work in the future.

    If you need to get monitoring data into the widget, you might want to look at the various examples of datasources that directly modify widgets on these forums like: a href="" rel="">

  • My thought for passing data from frame to frame was to write to temp properties of the dashboard and use them in the other widgets.  I was going to use something like this to make a slicer so you could have a list of devices in a graph and select which ones you want to have show up.