You are viewing limited content. For full access, please sign in.

Question

Question

Calculate 1st day of Following Month from Date Field

asked on February 24, 2016

Is it possible using Forms 10 to take a value from one date field and calculate the 1st day of the following month from that value and populate another field?

1 0

Answer

SELECTED ANSWER
replied on March 1, 2016

Hi there,

=DATE(IF(MONTH(Date)%12 + 1 = 1, YEAR(Date) + 1, YEAR(Date)), MONTH(Date)%12 + 1, 1) and output to a date field.

Is this what you need?

0 0
replied on March 8, 2019

I have a similar question but don't know how to modify this formula. I'm preparing a timesheet and have the first day of the pay period and want each day after to populate. So I have day 1 (say March 8, 2019, aka PPStart Variable) and want to essentially do, PPStart+1 for March 9, 2019 in one field. Then in another field I want PPStart+2 for March 10, 2019, and so on.

How do I modify the formula to do this?

0 0
replied on March 8, 2019

Oh, nevermind. It was literally as easy as =PPStart+1

0 0

Replies

replied on February 24, 2016

You can use moment.js for this.

I have a sample form with a date field for input (CSS class name inputDate), another date field to display the first day of next month (CSS class name nextDate), and a single line field to display the name of the day that's the first day of next month (CSS class name nextDay). Place the moment.js file into your C:\Program Files\Laserfiche\Laserfiche Forms\Forms\js folder. Then you can use

$(document).ready(function () {
  
  $.getScript('http://server/Forms/js/moment.js')
    
  $('.inputDate input').on('change', function() {
    $('.nextDate input').val(moment($(this).val()).add(1,'months').startOf('month').format('M/D/YYYY'));
    $('.nextDay input').val(moment($(this).val()).add(1,'months').startOf('month').format('dddd'));
  });

});
1 0
replied on February 24, 2016

First thing that came to my mind was workflow date time calculator, but you mentioned forms. I would recommend Javascript something like this.

http://stackoverflow.com/questions/10931288/how-to-add-subtract-dates-with-javascript

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.