Add 16 days to a date in Writer

Is there a way to do this in Writer:

  1. I click on a Field.
  2. I enter a date.
  3. It would return with a date + 16 days.

I’ve tried researching about macro, but I could only find this:

Sub example_dateadd
MsgBox DateAdd(“d”, 16, “1/31/2004”)
End Sub

I think it would only add 16 to a pre-set number.

I want to click on a field, so that I could input it myself.

Thank you for the help

Hi

Another proposal:

  • Define a variable (named InputDate in Add16.odt) used in an input field
  • Insert an other variable (eg. named Add16) with value InputDate+16

HTH - Regards

The “Add16” variable is not necessary - you may simply use F2 to add a field with the expression InputDate+16 without introducing a variable.

Thank you very much for this. Although the answer below works well, I would like to learn this approach. Can you please explain this more. I am new to this.

How can you “Define a variable and used in an input field?”
Then how can you “Insert an other variable (eg. named Add16) with value InputDate+16”

Also, what does this mean? “The “Add16” variable is not necessary - you may simply use F2 to add a field with the expression InputDate+16 without introducing a variable.”

Thank you again.

This approach with the variable is much more versatile if you need to use the date throughout your document.

You create fields by InsertFieldMore Fields.... You create a variable using Variables tab in the dialog, Set Variable field. You may use Input Field there to change the variable value later more conveniently. You may define other variables using previous variables (as suggested by @PYS ), or you may use Insert Formula (F2) to just count without new variable.

Thank you very much @mikekaganski and @Pierre-yves samyn. I finally got it. This will help me a lot.

Another question though. Is there a way so that the 16 days will only include weekdays (M-F). It will not count saturdays and sundays. Thanks.

For that kind of math, you need Calc. Possibly that’s what you needed from the start, not Writer.

Thanks you @mikekaganski. This is more of a text document with just a minor computation on dates. But your suggestions will do. Thank you!

  1. Create a 1-row 2-column table.
  2. In its A1, put a date, e.g. 2018-07-21.
  3. In its B1, start entering the formula by entering equal sign, then clicking A1, then adding required number: =<A1>+16. Finish the formula by Enter.
  4. The B1 cell will be formatted as number (and thus have the result 43318). Right-click B1, and choose Number Format...; then select Date.

You may also need to check that you have TableNumber Recognition checked.

Of course, you may have 3-cell table, and use B1 to enter number of days, and C1 to add B1 to A1… or whatever you need.

Here is a sample.

Thank you very much. This will come in handy. I did not know LO can do this.