Calculate a date a year from given date

Hi there

Can you please tell me what the formula is to calculate a date a year from a given date.

Many thanks

Hi,

Hope this helps?

Loc:Date LONG

MONTH(Loc:Date) = MONTH NUMBER eg 1-12
DAY(Loc:Date) = DAY eg. 1-31
YEAR(Loc:Date) = YEAR eg 1809 …

expanding a little on what Marius_Nel said:

givenDate long   ! some given date
plusYear  long   ! the given date plus a year

  code
  plusYear = date(month(givenDate), day(givenDate), year(givenDate)+1)

you may need to consider if given date is February 29th, do you want Feb 28th or Mar 1st in the following year.

cheers

Geoff R

1 Like

This tool has a Date Calculations tab to try the calculation without writing code and see it work. You can add 1 year using the DATE() function as Geoff showed.

1 Like

Hi Carl.
Thanks so much for your input. I am a newbie at Clarion and using version 8. I need to calculate the date for a field.

I wrote a servicing program and need to return the anniversary date to that field. Don’t know how your app will help.

Once again thanks very much for your help.