telly Posted January 26, 2019 Report Share Posted January 26, 2019 I need to find a workaround to generate an expiration date that is 2 years from the 1st day of the month. So, if I enter a value on 02/25/2019, Their expiration date to be 02/01/2020. Kindly help me with this, please? Quote Link to comment Share on other sites More sharing options...
SunakoChan Posted January 26, 2019 Report Share Posted January 26, 2019 Hi @telly, You may try this possible workaround. 1. On your Submission DataPage, go to Configure Fields and add a Header and Footer Element 2. Go to the Footer and disable the HTML editor by going to the Advanced tab and unchecking the box next to "Enable HTML editor". 3. Click the Standard tab. 4. Add the following code to add 2 years and always set it to the 1st day JavaScript code: <script> //detect event onchange on the textfield of certificate date document.getElementById('InsertRecordLast_InsertDate').onchange = function(event){ //place value of certificate date into a new Date class and put it in a variable var InsertDate = new Date(document.getElementById('InsertRecordLast_InsertDate').value); //get the first day of the same month but 2 years after var lastDate = new Date(InsertDate.getFullYear() + 2, InsertDate.getMonth(), 1); //date.getMonth() starts from 0, so add 1 then make sure it displays with 0 when lower than 10 if(lastDate.getMonth() < 9) { var lastMonth = "0" + (lastDate.getMonth() + 1); } else { var lastMonth = (lastDate.getMonth() + 1); } //place the value to the expiration date textfield document.getElementById('InsertRecordExpiration_Date').value = lastMonth + "/1/" + lastDate.getFullYear(); } </script> telly 1 Quote Link to comment Share on other sites More sharing options...
DefinitelyNot31337 Posted January 27, 2019 Report Share Posted January 27, 2019 Try to use this syntax in a formula field or Calculated Field: What is does is: 1.) Add 2 Years to the current Date 2.) Get the First Day of the resulting date by: subtracting the current (DAYofMonth-1) to the resulting date. DATEADD( YEAR, 2, DATEADD( DAY, 1 - DAY([@field:date]), [@field:date] ) ) Hope this information helps. Regards, DN31337 telly 1 Quote Link to comment Share on other sites More sharing options...
TsiBiRu Posted January 28, 2019 Report Share Posted January 28, 2019 On 1/26/2019 at 9:23 PM, DefinitelyNot31337 said: Try to use this syntax in a formula field or Calculated Field: What is does is: 1.) Add 2 Years to the current Date 2.) Get the First Day of the resulting date by: subtracting the current (DAYofMonth-1) to the resulting date. DATEADD( YEAR, 2, DATEADD( DAY, 1 - DAY([@field:date]), [@field:date] ) ) Hope this information helps. Regards, DN31337 Hi @telly, This solution is great, for more details about how to set up a calculated field in your DataPage you may refer to the links below.https://howto.caspio.com/datapages/datapage-components/calculated-values/https://howto.caspio.com/faq/reports-datapages/calculated-fields-and-datediff-function/ I hope this helps. Regards, TsiBiRu telly 1 Quote Link to comment Share on other sites More sharing options...
TroubleShooter Posted February 4, 2019 Report Share Posted February 4, 2019 In addition to @DefinitelyNot31337's definitely genius solution, in case you're wondering how to get the last day of the current month, you may to use this syntax: DATEADD( month, 1, DATEADD( DAY, -DAY('[@cbTimestamp*]'), '[@cbTimestamp*]' ) ) Hope this helps, TroubleShooter DefinitelyNot31337 1 Quote Link to comment Share on other sites More sharing options...
astroboy Posted November 29, 2020 Report Share Posted November 29, 2020 On 1/25/2019 at 4:23 PM, telly said: I need to find a workaround to generate an expiration date that is 2 years from the 1st day of the month. So, if I enter a value on 02/25/2019, Their expiration date to be 02/01/2020. Kindly help me with this, please? Hello there, I think it would be a great addition to your workflow if you can add a reminder sent via email to give a heads up to your users regarding their subscription to your application. I've stumbled upon this video tutorial that really helped me a lot with my application and I hope it helps your application too. Here's the link: 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.