Trying to add number or subtract number of days from given date, cant

I feeel like this should be a simple task but i cant for the life of me figure out how to do this without crazy formulas or helper tables. Is it not posible in glide to just date+days?

1 Like

You can’t directly add days to a date, but you can add to the timestamp.

  • Add a Number column (DaysToAdd)
  • Use a Math column:
    date + (DaysToAdd * 86400000)
    86400000 is the number of milliseconds in a day
  • Set the output type of the math column to “Date/Time”

It is not needed. As long as you put in a valid date/time column, the Date + Days operation can work normally.

Please check when I use D+1 here.

1 Like

i did a horrible job explaining this ! i need to do this taking weekends and holidays in account.

1 Like

So if you add days, you want it to skip over weekends and holidays, and basically calculate to the next business day?

So if you added 14 days to today June 22nd, meaning it would cross two weekends and the July 4th holiday, what would you expect for an end result. Trying to determine if you are in fact skipping all weekend and holiday days, or just adding 14 days and then rounding to the next business day.

1 Like

i have a start day and then adding how many work days job takes to get the finish date. make sense?

1 Like

In Google Sheets, I used to work with the WORKDAY & NETWORKDAYS formulas, but I haven’t done anything like it in Glide before. On the bright side, you got Jeff’s attention, so don’t worry. :slight_smile:

You didn’t really answer Jeff’s questions clearly. This is important. If you want good help and avoid wasting time, you must be clear and specific.

  • How do you define a work day? (Monday to Friday? Monday to Saturday? Sunday to Thursday?)
  • Do you need to take Public Holidays into account?
  • If yes, do you have a list of all Public Holiday dates for your location?

Your challenge is easily solvable, but we just need to be clear about the end goal, otherwise you may end up with the wrong solution.

3 Likes

I haven’t had a chance to sit down and work something out today. Life is crazy busy for me during the summer months. But I think I would make use of javascript in this case.

Create a javascript column where you pass in the start date, the number of business days to add, and a comma delimited list (or JSON) of holiday dates. I think my goal would be to have it return a modified number of days after accounting for weekends and holidays. Then use a regular math column to add that modified number to the start date. So ultimately two columns to work it out. Could all be done in javascript to return a date, but it doesn’t return as a date type so that’s why I would have it return a number of days to then use in a math column which does return a date type. That’s at least how I would probably approach it.

3 Likes

Sorry, work days are sat and sundays + holidays i went ahead and built a helper table and am procesing throught that, was really hopping i would not have to do that but plentey of great features in Glide so small price to pay i guess. Thanks!