cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding converting date fucntion(UDF)

Former Member
0 Kudos

Hi

In the source my date format is byyddd

b-blank yy-08 ddd-219

In the target i have to convert this into YYYYMMDD

please give me some inputs for udf creation.

Regards

venkat.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

This can be achieved very easly by using the standard function "DateTrans".

Double click on "DateTrans" function and then enter "yyddd" in Format of Source Date and enter "yyyyMMdd" in the Target Format.

You are done, no need to think about leaf year or count the number of days in a month this function will take care every thing. )

I have used this before, so test it and let me know if you face any problems..

Regards,

Sarvesh

Former Member
0 Kudos

hi venky,

could you please let us know what exactly ddd-219 refers to??

Is it the combination of date(21) and month(9) or, vice versa.

Regards,

Swetha

Former Member
0 Kudos

Hi

ddd is no of days

regards

venkat.

Former Member
0 Kudos

use class simpleDateFormat.parse method for converting date to your date format . Google it for this you can get help on this

Rajesh

former_member181955
Contributor
0 Kudos

Hi

First you need to find out the leaf year or not then you need to work on the date.

you can get the month as putting the condition as follows

Month:

Month = 01 if "ddd" between 1 and 31

month = 02 if "ddd" between 32 and 59 (60 Leaf Year)

For Example:08219

YYYY=2008 is leaf year

Month = Aug as "ddd" between 214 and 244

Date = Total nubmer of days - number of days till July(213) a month before the actual month.

219 - 213

Hope it may help you.

Thanks

Prasad Nemalikanti

Former Member
0 Kudos

Hi venky,

Your date format is something new.

I have a few doubts but ill go ahead with the logic..see if it suits your description.

Firstly, it is really easy to extract the date and year. Since your input is a fixed format all you need to do is get substring(1,3) to extract the date. Save this in a string and concatenate 20 to the existing 08 to make it 2008.

Similaly extract the ddd field by using the substring function. Your ddd is 219. so here im assuming that 19 is the date and 2 is the month. but then again is the problem with the month 10,11,12.

Anyway extract the date and save it in another string.

Concatenate all the strings one by one to obtain the desired format.

Personally i wuold recommend changing the input format to replace the byyddd by yymmdd and then go ahead with the udf.

Regards,

Kshitij