UI Only formula field to add days to a date

Hey! I want to add certain number of days to a date using UI only formula field in skuid. But I’m unable to achieve this in Skuid. Is there any other solution for this??

This post gives an example of working with dates in a UI only that you can use as a template http://community.skuid.com/skuid/topics/calculate-age-with-ui-only-field

V Chinmay,

I don’t think there is a way to use a UI formula field to add days to a date.  Depending upon your needs,  I would add a custom formula field in Salesforce that will return a date so many days in the future.  If you need the future date as part of the Skuid page, then you’ll need to do this with a Snippet.

Thanks,

Bill

Skuid Community,

I needed this myself.  Here is the code for a Custom Formula Field function to add days to a date field:

skuid.formula.Formula (
  ‘ADD_DAYS’,
  function (fieldName, daysToAdd) {
      if(fieldName !== null && fieldName !== undefined ) {
      if(daysToAdd===null || daysToAdd===undefined || daysToAdd===‘’) {
      daysToAdd = 0;
      }
    var jsDate = skuid.time.parseSFDate(fieldName);
    //add days
    jsDate.setDate(jsDate.getDate() + daysToAdd);
    //convert from Javascript date back to Salesforce date
        return skuid.time.getSFDate(jsDate);
    } else {
        return null;
    }
  },{
    namespace: ‘dateFunctions’,
    numArgs : 2,
    returnType : ‘date’
  }
);
//
// Usage
// dateFunctions__ADD_DAYS({{Date_Field__c}}, 30)
// dateFunctions__ADD_DAYS({{Date_Field__c}}, {{daysToAdd}})
//
// Where’
// {{Date_Field__c}} is a field of type = DATE
// {{daysToAdd}} is a NUMBER or TEXT field represting the number of days to add

Thanks,

Bill

Thank you Bill!