Jump to content

Generate an expiration date


Recommended Posts

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 
 

sample.thumb.png.a1f4ea4989fef7a81741fc5a1e36ca76.png


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>

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 year later...
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: 

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...