Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Is there a "Date add" function  (Read 2667 times)

edwinantonykc

  • Newbie
  • *
  • Posts: 2
    • View Profile
Is there a "Date add" function
« on: April 26, 2018, 02:38:30 pm »
I am creating a Invoice using lime report. I need to make a date calculation here.
I have two variables InvoiceDate and DueDate. Assume the InvoiceDate is 26-04-2018 and DueDate is 15 then, I need to calculate 15 days from 26-04-2018 and show the result 11-05-2018 in a Text Item. Is that possible to do in the report?. Kindly help me.

Arin Alex

  • Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 1005
    • View Profile
Re: Is there a "Date add" function
« Reply #1 on: May 07, 2018, 10:55:44 am »
Hi!
You can add this javascript function to init script
Code: [Select]
function addDate(date, dayCount){
  var lDate = new Date(date);
  lDate.setDate(lDate.getDate()+dayCount);
  return lDate;
}
and use it in TextItem like this:
Code: [Select]
$S{dateFormat(addDate(now(),15))}

edwinantonykc

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Is there a "Date add" function
« Reply #2 on: May 09, 2018, 10:05:52 am »
Hello,

Thank you very much for the reply and solution. Great job.. All the best and success

Regards,

Edwin Antony