Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

add-months and add-one-month functions

add-months: func [
    date [date!]
    count [integer!] "Number of months to add"
    /local res
] [
    res: make date! reduce [date/day date/month + count date/year]
    ; If date/day is greater than the last day in the calculated
    ; month, we'll be at count+1 months, so we walk backwards until
    ; we find the last day of the previous month.
    while [(res/month - date/month) > count] [res: res - 1]
    res
]

add-one-month: func [date [date!]] [add-months date 1]
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS