Tubby Posted February 17, 2023 Report Share Posted February 17, 2023 Hi guys, this is not a question but I just want to share a solution that I made using js. I was needing a way to on load get the first and last day of the current month and use that as my initial search values in a tabular report but I am struggling to find a way without using js. Here is the script that I came up with: <script type="text/javascript"> document.addEventListener('DataPageReady', function (event) { var date = new Date(), y = date.getFullYear(), m = date.getMonth(); var firstDay = new Date(y, m, 1); var lastDay = new Date(y, m + 1, 0); var criteria1 = document.getElementById("Value1_1").value = firstDay.toLocaleDateString("en-US"); var criteria2 = document.getElementById("Value1_2").value = lastDay.toLocaleDateString("en-US"); }); </script> I got this from https://stackoverflow.com/questions/13571700/get-first-and-last-date-of-current-month-with-javascript-or-jquery and simply use toLocaleDateString to format the values to dd/MM/yyyy instead of the long date used by default. Just don't forget to inspect the input fields first in the preview to check what is the field's ID then simply change the colored values. Cheers! Ilyrian 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.