Page 1 of 1

Need Logic...

Posted: Fri Aug 26, 2011 3:49 am
by praburaj
Hi,
I have one date column in my source table. The date i need to calculate based on four quarter months basis. Means 1st quarter - Jan to Mar 2nd Quart-Apr to Jun 3rd Quart-July to Sep 4th Quart-Oct to Dec.

If my source date comes between first quarter like this Ex: 3/14/2005 then my First Date should be 1/1/2005 and End Date Should be 12/31/2005 and if my source date comes between 2nd quarter like 4/2/2006, then my First Date should be 4/1/2006 and End Date Should be 3/31/2007.

Show me a right direction how to achieve this.

Posted: Fri Aug 26, 2011 4:47 am
by dxk9
You can use the substring or left function and fetch the first character of your date field. Then based on that, you can default the date to the required date.

For eg:
a. if your input date is '3/14/2005', then your substr or left function will give the reply as '3', then you can default the date with 1/1/2005.

b. Once your month & date part is done, you can append the year depending on the input date value using right, substr, year functions

This is just a logic to go around... you might have to do some trial & error with the logic.

Regards,
Divya

Posted: Fri Aug 26, 2011 5:48 am
by ray.wurlod

Code: Select all

Int((MonthFromDate(InLink.TheDate)-1)/3)+1