Hello,
What is the easiest way to add a year to a date?
If I do Date()+365, I will have an error with leap years.
Hello,
What is the easiest way to add a year to a date?
If I do Date()+365, I will have an error with leap years.
Enrico's method fails if "next year" is a leap year and the date sought is after February.
Il 31/10/2022 16:58, dlzc ha scritto:
Enrico's method fails if "next year" is a leap year and the date sought is after February.
Ops, you are right!
nDate := AddMonth(Date(), 12)
Am 31.10.2022 um 18:47 schrieb Enrico Maria Giordano:
Il 31/10/2022 16:58, dlzc ha scritto:
Enrico's method fails if "next year" is a leap year and the date
sought is after February.
Ops, you are right!
Use function AddMonth from xHarbour.
nDate := AddMonth(Date(), 12)
R. Berning
Thanks so much that fixed the problem, you help is appreciated
Otto
Le 31/10/2022 à 19:58, Rainer Berning a écrit :
Am 31.10.2022 um 18:47 schrieb Enrico Maria Giordano:
Il 31/10/2022 16:58, dlzc ha scritto:
Enrico's method fails if "next year" is a leap year and the date
sought is after February.
Ops, you are right!
Use function AddMonth from xHarbour.
nDate := AddMonth(Date(), 12)
R. Berning
i have this simple method:
if (year(yourdate+nnn))/4=int((year(yourdate+nnn))/4)
'this is leap year'
Hi,ingo:
"timepro timesheet" <timec...@gmail.com> schrieb:
i have this simple method:
if (year(yourdate+nnn))/4=int((year(yourdate+nnn))/4)this is not correct. Look at the definition of a leap year [1].
'this is leap year'
Regards Ingo
[1] https://en.wikipedia.org/wiki/Leap_year#Algorithm
--
Threema - Sicherer und privater Messenger: https://threema.ch/de
Meine Threema-ID: https://threema.id/ZV9BWDXK
Warum Threema? https://warumthreema.de/
but does anyone contemplate (while) coding for year 2100 onward...
Am 31.10.2022 um 18:47 schrieb Enrico Maria Giordano:
Il 31/10/2022 16:58, dlzc ha scritto:
Enrico's method fails if "next year" is a leap year and the date sought is after February.
Ops, you are right!
Use function AddMonth from xHarbour.
nDate := AddMonth(Date(), 12)
nDate := AddMonth( , 12) (or maybe just ->AddMonth(12) )... since it says it defaults to system date
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 339 |
Nodes: | 16 (0 / 16) |
Uptime: | 07:02:08 |
Calls: | 7,467 |
Calls today: | 3 |
Files: | 12,691 |
Messages: | 5,626,260 |