Ask Your Question
1

Add 16 days to a date in Writer

asked 2018-07-21 13:49:29 +0100

Ibelin123 gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2018-07-21 14:43:58 +0100

pierre-yves samyn gravatar image

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

image description

HTH - Regards

edit flag offensive delete link more

Comments

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

Mike Kaganski gravatar imageMike Kaganski ( 2018-07-21 14:50:26 +0100 )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.

Ibelin123 gravatar imageIbelin123 ( 2018-07-21 15:31:50 +0100 )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.

Mike Kaganski gravatar imageMike Kaganski ( 2018-07-21 15:38:03 +0100 )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.

Ibelin123 gravatar imageIbelin123 ( 2018-07-21 17:18:49 +0100 )edit

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

Mike Kaganski gravatar imageMike Kaganski ( 2018-07-22 01:57:56 +0100 )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!

Ibelin123 gravatar imageIbelin123 ( 2018-07-22 03:03:17 +0100 )edit
1

answered 2018-07-21 14:16:40 +0100

Mike Kaganski gravatar image

updated 2018-07-21 14:31:39 +0100

  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.

edit flag offensive delete link more

Comments

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

Ibelin123 gravatar imageIbelin123 ( 2018-07-21 15:21:32 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-07-21 13:49:29 +0100

Seen: 52 times

Last updated: Jul 21 '18