Iam having the date difference issue
I have a col1 with some codes like A,B,C and another col with dates ,date column in this format 20100724
So my condition is that if Col1 is 'A' then populate a column with the one year reduced that is difference 1. Can you please help me with this issue
Example: if col1='A' then ( 20100724) in the result i should get 20090724
date difference
Moderators: chulett, rschirm, roy
Re: date difference
You can do something like That should work. The only challenge for you is to put in some additional logic when the Date you have is a leap Year and it is Feb 29. Then the last year date would be Feb28 of that year.
Hope that helps.
Code: Select all
If Col1 = 'A' Then Date[1,4] - 1: Date[5,8]
Hope that helps.
Kris
Where's the "Any" key?-Homer Simpson
Where's the "Any" key?-Homer Simpson
-
- Participant
- Posts: 89
- Joined: Sat Jul 24, 2010 11:33 pm
Re: date difference
Hi Kris,kris007 wrote:You can do something likeThat should work. The only challenge for you is to put in some additional logic when the Date you have is a leap Year and it is Feb 29. Then the last year date would be Feb28 of that year.Code: Select all
If Col1 = 'A' Then Date[1,4] - 1: Date[5,8]
Hope that helps.
Iam doing the difference for year only.
-
- Participant
- Posts: 89
- Joined: Sat Jul 24, 2010 11:33 pm
Re: date difference
Hi Kris,kris007 wrote:You can do something likeThat should work. The only challenge for you is to put in some additional logic when the Date you have is a leap Year and it is Feb 29. Then the last year date would be Feb28 of that year.Code: Select all
If Col1 = 'A' Then Date[1,4] - 1: Date[5,8]
Hope that helps.
Iam doing the difference for year only.
Re: date difference
Yes. But what if your input date is 20080229. What should be your output? 20070229 (which is invalid) or 20080228.
Kris
Where's the "Any" key?-Homer Simpson
Where's the "Any" key?-Homer Simpson