Scottster Posted April 9, 2015 Report Share Posted April 9, 2015 I am trying to add a variable number of days to a date field. Here is my script: var v_NewDate = new Date(); v_NewDate.setDate(v_NewDate.getDate() + v_LeadTime); If I use todays date (April 9, 2015), and v_LeadTime = 10, I receive the value "Tue Sep 26 2017 13:36:25 GMT-0500 (Central Daylight Time)". Can someone explain what I am doing wrong? Thanks Quote Link to comment Share on other sites More sharing options...
Jan Posted April 11, 2015 Report Share Posted April 11, 2015 Hello Scottster, Could you please provide the whole script or the URL of your page? I have tried with the following script: <script> var v_NewDate = new Date(); var v_LeadTime = 10; v_NewDate.setDate(v_NewDate.getDate() + v_LeadTime); alert(v_NewDate); </script> And I have got the correct date, April 21th. Quote Link to comment Share on other sites More sharing options...
Scottster Posted April 19, 2015 Author Report Share Posted April 19, 2015 function CalcArrivalDate(){var v_LeadTime = document.getElementById("InsertRecordLeadTime").value;var v_ShipMethod = document.getElementById("InsertRecordShipMethod").value;if (v_ShipMethod == "Ocean"){ var v_NewDate = new Date(); v_NewDate.setDate(v_NewDate.getDate() + v_LeadTime); document.getElementById("InsertRecordEstimatedArrivalDate").value = v_NewDate;}} Quote Link to comment Share on other sites More sharing options...
Kurumi Posted April 8, 2019 Report Share Posted April 8, 2019 Hi @Scottster, You could try using the Calculated Value and use DATEDIFF formula for days just like this one: DATEDIFF(DAY, [@field:DateTime], GETDATE()) Caspio introduced new features which you can find here: https://howto.caspio.com/release-notes/caspio-bridge-13-0/ This release includes a new feature, Calculated Values in Submission Forms. This allows you to generate calculations which you can use for you to get the number of days. I hope this helps! Quote Link to comment Share on other sites More sharing options...
Aether Posted April 8, 2019 Report Share Posted April 8, 2019 You can also use trigger action or task in adding a number of days for your Date Field that is saved in your table. For example: here some documentation about DateDiff function in a calculated field if you needed it also: https://howto.caspio.com/faq/reports-datapages/calculated-fields-and-datediff-function/ I hope this helps Quote Link to comment Share on other sites More sharing options...
RuisiHansamu Posted July 19, 2021 Report Share Posted July 19, 2021 (edited) Hello! I just wanted to share that we can add certain days in a calculated field or formula. You can try this formula: DateAdd(day, 30, [@field:date]) Then, it will now indicate the number of days that you inserted inside your formula. As you can see on my end, this is what it looks like: The Date add is the calculated field. The date from 6/1/2021 adds 30 days that is why it displays the 7/01/2021 date. I hope this helps! cheers! Edited July 19, 2021 by RuisiHansamu Duplicated screenshot mostafij 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.