Page 1 of 1

how to get next or previous month from existing one

Posted: Tue Aug 19, 2008 11:54 pm
by pxraja
Hi all,

I am having on scenario like.. I want to allow the records for the previous month and again after a month it has to be repeated with previous month incremented.
for example

there are 4 fields inthat Inlink.Field1 has value like 'May 08'

Inlink.Field1 Inlink.Field2 Inlink.Field3 Inlink.Field4
'May 08' '323' 'like' 'nike'
'Apr 08' '234' 'xmdjk' 'dkfadl'

next month the record coming is

Inlink.Field1 Inlink.Field2 Inlink.Field3 Inlink.Field4
'Jun 08' '432' 'dkdfa' 'dlkjfd'
'May 08' '323' 'like' 'nike'
'Apr 08' '234' 'xmdjk' 'dkfadl'

I want to allow the June month records only not all the records, like

Outlink.Field1 Outlink.Field2 Outlink.Field3 Outlink.Field4
'Jun 08' '432' 'dkdfa' 'dlkjfd'
'May 08' '323' 'like' 'nike'
'Apr 08' '234' 'xmdjk' 'dkfadl'

I am using the following transform to get the previous month first date

Oconv(Iconv(InLink.Field1,'D MY[A3,2]'),'DYMD')

But how to get previous month +1 , month ? is there any functions like NEXTMONTH() as in oracle ? or how to proceed with this? any suggestions are welcomed

thanks in advance

Posted: Wed Aug 20, 2008 1:21 am
by ray.wurlod
Take a look at the available Transforms, particularly MONTH.TAG, MONTH.FIRST and MONTH.LAST.

Since the latter two return internal format dates, if you subtract 1 from the result of MONTH.FIRST you have the date of the last day of the previous month.

If you insist on working with Iconv() and Oconv() then you could do worse than learn about date conversion

Posted: Wed Aug 20, 2008 4:20 am
by pxraja
ray.wurlod wrote:Take a look at the available Transforms, particularly MONTH.TAG, MONTH.FIRST and MONTH.LAST.

Since the latter two return internal format dates, if you subtract 1 from the result of MONTH.FIRST you ...
I am using the following code to get the next month starting date,

MONTH.FIRST(MONTH.TAG(Iconv (DSLink2.C_MONTH,'D MY[A3,2]')))+1

the value returned in Outlink.field1 is 14733

but it works for the above. If I add Oconv(MONTH.LAST(MONTH.TAG(Iconv (DSLink2.C_MONTH,'D MY[A3,2]')))+1,'D YMD')

i am getting the next month first date,i.e., '2008 06 01'
also i want last date also i.e, '2008 06 30'

for that i'm trying like this
Oconv(MONTH.LAST(MONTH.TAG(Iconv (DSLink2.C_MONTH,'D MY[A3,2]')))+1,'D YMD') written to stage variable 'NextMon'

Oconv(MONTH.LAST(MONTH.TAG(NextMon)))

the Outlink.Field1 is NULL for the above expression

why is so? is there any thing I am missing? your suggestions will be most welcomed

thanks in advance


can anyone tell me why it's not returning any value

Posted: Wed Aug 20, 2008 5:19 am
by ray.wurlod
Open each of the supplied transforms and note the expected format of input.

Please also post a message showing how you resolved this, since you have marked the thread as Resolved.