Add shortcut to increment/decrement date by a day?

How would I start doing this? It would make entering financial transactions so much nicer.

I would also like to a shortcut to increment or decrement a number by say 1000 or 10.

As a side note, org-mode in Emacs has this shortcut C-c up/C-c down which you can apply to the year/month/day to increment or decrement date by that period.

I cannot test with a Linux currently, and I don’t know therefore if the modifiers used “extensively” by my proposed code are also working there. If you test the code, please report.
(Anyway I only tested successfully under Win with LibO V5.4 and 6.0+. A few older versions I tested with didn’t support the “modifier event” sufficiently:)

I don’t think something of the kind is implemented. You will need user code (in your case custom code?) for the purpose.
Always concerned to make “financial transactions nicer” (for other people), and when feeling a little bit bored, I designed a usable solution.
It is contained in this attachment. Check the code for beeing clean (no malware) and reload it with permission for macro execution.
The document comes with a special little toolbar with only one sensitive area labeled IncDec.
Together with the modifiers Shift/Ctrl/Alt it should be sufficiently flexible. The usage is explaind in the sheet.
Have a lot of fun.
If you decide to actually use the code in the long run you should

  • move it to your local ‘Standard’ library,
  • add the Sub for direct call to an appropriate toolbar,
  • consider to donate to a foundation supporting a children’s hospital (or something of the kind).

===Edit 2020-03-13 about 22:10 UTC===
On a long walk I got a hunch there might be an issue with the DateSerial function of Basic - and there was. It is unable (unwilling) to allow for carries caused by excess month or day ordinals. The comparable Calc function DATE handles carries as needed for the purpose, and I reworked the code to use DATE via a FunctionAccess object. In addition I decided to also implemet treatment for values formatted ‘TimeOnly’ (independent of whether or not they have a hidden date part). The logical (Boolean) format is now also handled - by simple negation.
I would suggest you use (if at all) the new version contained in this new attachment. I even consider to use the tool myself. A test is started.

[Edit 2021-09-09 about 21:40 GMT]
Having seen due to a question in a forum that incrementing and decrementing may be a topic for many users, I reworked the old example slightly, simplified the handling a little bit, and added functionality for some purposes. A guiding principle still is to regard the number format of the cell having the focus, and therefore being processed. The step widths depend on that type, and in case of numers formatted the “scientific” way, by default inc/dec works with the exponent (what results in the application of a factor). The modifier Alt is no longer used for “decrease” (extra area in the toolbar now) and can therefore help with disambiguations concerning DateTime and Scientific.
Due to the extensive functionality, it’s necessary, of course, for users to talke some time for getting familiar with the tool. It should then be useful in some cases. (I personally don’t need it currently.)
Please note: Opening the example you will most likely find the special document toolbar docked and locked somewhere. Yo can unlock it and move it to a place nbetter suiting you.
If you actually start long-term usage, you will place the tool bar in the standard area anyway, and move the relevant module incdec to your Standard library. (Resolve name conflicts if any!)
New example containing the reworked code:
ask233471_IncrementDecrementByModifiedToolbar20210909.ods (31.6 KB)
[/Edit]

@Lupp: Great! Would you possibly consider DateAdd? (I filed tdf#131332 regarding the help page :-))

And also consider making it an extension with some pre-configured keyboard shortcuts?

Thanks for hinting me to the ‘DateAdd’ function. However, I tend to challenge rarely used Basic functions due to the fact that there may be some users NOT reporting bugs they tumbled over. At least @mikekaganski once told me so. Bugs reported but not fixed are also said to occur. To convince myself of the trustworthyness of a Basic function of the kind I would need extensive testing. Anyway I don’t understand how to use the ‘Add’ strings “w” and “ww”.
Concerning the extension case: I never did it. I would need help. I’m 75 and learning new things slowly. (There are also fields where I am making fast progress. In forgetting I’m a champion.)
“Great” answers deserve upvoting. :wink:

However, I tend to challenge rarely used Basic functions due to the fact that there may be some users NOT reporting bugs they tumbled over

That’s nice and encouraged; yet I cannot understand in what context was that said (i.e., which rarely used function you refer to; and if my proposal somehow conflicts with the said challenging).

(I’m looking at what those “of year” mean in the context of the function.)

Concerning the extension case: I never did it

… me too :wink: My friend did that when he prepared some extensions I helped to code.

“Great” answers deserve upvoting. :wink:

You are absolutely right! I must remind that myself more often.

Anyway I don’t understand how to use the ‘Add’ strings “w” and “ww”

The three options: "y", "w", and "d", appear to do exactly the same in SbRtl_DateAdd: they add 1 day to the passed date, without any other fancy processing. There are other functions that differentiate them: DateDiff and DatePart. The interval strings used in all these functions are unified.

I suppose DateAdd to be “rarely used”. I may be wrong.
The comment I (roughly) quoted you with from memory wasn’t about Basic specifically. That wasn’t very long ago, but I cannot find it now.
From memory again: IsNumeric("+1") = false, IsNumeric("-1") = true. Where - and with what justification - is this specified?
Besides missing specifications there are many doubtable ones. (I now the logic of this sentence is broken.) ODF (1.2 part 2, 1.3 part 4) worry (concerning the syntax of textual representation in the file described in RegfEx-enriched Backus notation) about numbers without an integer part - but don’t allow for signs except by mentioning that " negative numbers are positive numbers with a prefix ‘-’ ". As an exponent part “E+1” is accepted. Why?
ALGOL60 did it better! I can hardly cope with this way, and the few RFC I read didn’t taste well. …

@Lupp: the IsNumeric question seems offtopic?

Besides, ODF is unrelated to StarBasic (which might not have any standard at all, I’m afraid)…

But I can say that e.g. Excel’s VBA gives true for IsNumeric("+1")

So as you challenge those functions, I assume you also file the related bugs? :wink: I could only find tdf#123158 related to another problem with IsNumeric though.

@mikekaganski: I knew tha was off topic - in a sense. It was an example for my resons to distrust Basic functions, and what you told in your comments above enforced my opinion insofar.
That ODF and StarBasic are unrelated also is clear to me. Under some aspects they may suffer from similar diseases. We had that already more than once. You understand ODF manners to specify things better thn I do, obviously.
Thanks for your patience!