We have a field stored as Date type in the following format: 10/18/11. I am looking for options to increase the year by one (to 10/18/12). Any suggestions are highly appreciated.
Also, is my following understanding of DaysSinceFromDate() function right.
As to your example, no - it will return a -1. DaysSinceFromDate uses (source date,given date) and returns the days from the given date to the source date, and the 17th was one day earlier (-1) from the 18th. In order to get 1, you would have to reverse the dates.
I do not need to worry about the year after leap year. I compare two dates (to and fro) and if the fro date is less than the to date, then increase the year by one on the fro date. Thanks.
pdntsap wrote:I do not need to worry about the year after leap year. I compare two dates (to and fro) and if the fro date is less than the to date, then increase the year by one on the fro date. Thanks.
But as Craig noted, if you are doing as suggested, you really SHOULD address the leap year issue. If your from date is 02-29-2012 and you increase the year by one, you'll get 02-29-2013, which doesn't exist. Not a good thing.
You should check if the from date is 02-29; if it is, you'll need to change it to 02-28 before adding a year.