Page 1 of 1

Date to Integer in parallel edition

Posted: Tue May 16, 2006 11:52 pm
by spendem
Hi All,

I want tp covert a date value to an integer values and want to make a comparison with the currentdate().

Ex: IncomingDate = 2006-05-12
CurrentDate() = 2006-05-17

Requirement is: If IncomingDate = CurrentDate() Then X Else Y
I need to use above derivation on a tarnsaformer stage.

Can anyone helpme out on how to achieve this?

I am working on Enterprise Edition and Iconv and Oconv are not supported in parallel edition.

Posted: Wed May 17, 2006 1:41 am
by ray.wurlod
Why do you want to convert to Integer? CurrentDate() returns a Date, and presumably your input column also is of type Date. Have you tried the expression you posted? Obviously the values generated by the expressions X and Y must be of the correct data type for your output column.

Posted: Wed May 17, 2006 1:50 am
by spendem
Hi,
Thanks for your answer, Actually I am not populating the date column in the target I will be using the Incoming date from a feed file and need to compare it with the currentDate() of the system if both are same then I need to populate a different column based on this condition. Since date columns cannot be compared or rather they need be either a character data or numeric one for comparison. thats the reason I m looking for a conversion to Integer.

Many Thanks,
Spendem

Posted: Wed May 17, 2006 1:57 am
by ray.wurlod
Of course dates can be compared! Who said they can't?

Posted: Wed May 17, 2006 2:26 am
by spendem
Hi,
Can we achieve this comparison 2006-05-17 = 2006-05-17 in the transformer stage?
If yes then can you please explain? since I when tried using it, the derivation was invalid.

Many Thanks,
Sandeep S Pendem

Posted: Wed May 17, 2006 4:09 am
by spendem
Hi,
Its working..... What I did is I converetd the dates to DateTostring in the stage variables
And then I used them at the derivation(Transformer Stage) as,
If AsInteger(Date1) = AsInteger(Date2) Then X Else Y.

Cheers,
Spendem

Date to Integer Conversion

Posted: Wed May 17, 2006 4:42 am
by ashwin141
spendem wrote:Hi,
Its working..... What I did is I converetd the dates to DateTostring in the stage variables
And then I used them at the derivation(Transformer Stage) as,
If AsInteger(Date1) = AsInteger(Date2) Then X Else Y.

Cheers,
Spendem
Hi Spendem

But I guess there is no need to conver it to String and then do the comparison as Integer. Dates can be directly compared. Just check for the datatypes of two fields. I guess it will solve the problem.

Regards
Ashwin