# 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:

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

edit retag close merge delete

Sort by » oldest newest most voted

Hi

Another proposal:

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

HTH - Regards

more

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

( 2018-07-21 14:50:26 +0200 )edit

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.

( 2018-07-21 15:31:50 +0200 )edit

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 @pierre-yves samyn ), or you may use Insert Formula (F2) to just count without new variable.

( 2018-07-21 15:38:03 +0200 )edit

Thank you very much @Mike Kaganski 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.

( 2018-07-21 17:18:49 +0200 )edit

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

( 2018-07-22 01:57:56 +0200 )edit

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

( 2018-07-22 03:03:17 +0200 )edit
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.

more