on 02-11-2009 6:23 AM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.