Page 1 of 1

How to calculate a date

Posted: 2019-02-03 11:49:00
by vwnisus
I would like to know whether it is possible to have a macro where I am able to add (or go back)1 day to today's date.

I understand to get today's date:

Code: Select all

$today =
so $today = date. now + 1 day

Is there a(n easy) way to do this in Nisus Writer Pro?

Re: How to calculate a date

Posted: 2019-02-03 15:45:34
by phspaelti
As far as I know, Nisus Macro language is still case sensitive, so you'll need to write:

Code: Select all

$today =
To get the next day you have basically two methods, simpler:

Code: Select all

$nextDay = $today.dateByAddingSeconds 86400
…and fancier:

Code: Select all

$y = $today.year
$m = $today.month
$d = $ + 1
$nextDay = Date.newWithYearMonthDay $y, $m, $d
The latter method can be combined into 1 line, like so:

Code: Select all

$nextDay = Date.newWithYearMonthDay $today.year, $today.month, ($ + 1)