Hi All,
As the Built-in Date functions are not available in Server jobs (Like the YearFromDate(Input_date) iin Parallel jobs)
Can anybody help me to implement DateConversion in Server Edition?
I have tried using Oconv function as shown below
Oconv(Input_date, "D Y")
But this is not working... Am I missing anything here?
Is there any other method of Implementing Date and other conversions?
If Yes please share that also...
How to Convert Dates
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 22
- Joined: Fri Jul 12, 2013 7:32 am
How to Convert Dates
Rajendra
ETL Developer
InfoCepts
ETL Developer
InfoCepts
-
- Premium Member
- Posts: 376
- Joined: Sat Jan 07, 2012 12:25 pm
- Location: Piscataway
I think OCONV requires the argument in the internal format as generated by ICONV.
Jerome
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
Data Integration Consultant at AWS
Connect With Me On LinkedIn
Life is really simple, but we insist on making it complicated.
How to convert dates
Hi rajendra_89
You need to be more specific, what sort of converstion are you trying to achieve?
For example:
1- if you want to change from mm/dd/yyyy and the desired output is yyyy/mm/dd you may use the foolow:
Oconv(Iconv(DateAttribute,"DMDY"),"D/YMD[4,2,2]")
2 - If you want to add 2 days to the existing date and assuming input date is in the dd/mm/yyy format, you can do the follow:
Oconv(Iconv(InputFieldName,"DDMY") + 2,"D/DMY[2,2,4]")
Perhaps reading the "Server Job Developer's Guide" Chapter 7. BASIC Programming in page 239 will help.
regards,
Mario Fernandes
You need to be more specific, what sort of converstion are you trying to achieve?
For example:
1- if you want to change from mm/dd/yyyy and the desired output is yyyy/mm/dd you may use the foolow:
Oconv(Iconv(DateAttribute,"DMDY"),"D/YMD[4,2,2]")
2 - If you want to add 2 days to the existing date and assuming input date is in the dd/mm/yyy format, you can do the follow:
Oconv(Iconv(InputFieldName,"DDMY") + 2,"D/DMY[2,2,4]")
Perhaps reading the "Server Job Developer's Guide" Chapter 7. BASIC Programming in page 239 will help.
regards,
Mario Fernandes
Mario Fernandes
An expert is one who knows more and more about less and less. - Nicholas Murray Butler
An expert is one who knows more and more about less and less. - Nicholas Murray Butler
Server is very forgiving and technically everything is a string under the covers. If you want the year from a date I would just substring out those 4 characters. Or use the Field() function.
Yes, it does require an internal date format but IConv is not the only way to get that. Most of the built-in current date macros / system variables return that format from what I recall. Of course and as noted, dates coming in from other sources would need to first need to be converted to internal format via IConv if you really need the services that OConv bring to the table.jerome_rajan wrote:I think OCONV requires the argument in the internal format as generated by ICONV
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 22
- Joined: Fri Jul 12, 2013 7:32 am
Thanks for your inputs Jerome
I think Mario has given the solution for the point you mentioned
Meanwhile while working on the problem I have come up with the two solutions
My Date is in the format YYYY-MM-DD and I want to convert it to the format in one of the requirement as only YYYY and in the other requirement as only MM
First Solution goes like this
1. Substrings( Oconv(Input_Date,"D"),6,2) --for Month
2. Substrings( Oconv(Input_Date,"D"),1,4) -- For YEAR
And the Second solution is by using the Transform Built-in Sdk function
1. DateYearFirstGetYear(Input_Date) -- (For YEAR)
2. DateYearFirstGetMonth(Input_Date) -- (For Month)
And With Marios Hint I have got the third solution as
1. Oconv(Iconv(Data_In.DATE,"D/YMD[4,2,2]"),"DM") --For Month
2.Oconv(Iconv(Data_In.DATE,"D/YMD[4,2,2]"),"DM") -- For Year
Thanks Mario for your inputs as welll
Further Mario ,I request you to please provide me the link for Server Job Developer's Guide which you mentioned... I tried to find the Developers guide for the Server jobs but couldn't find...
I think Mario has given the solution for the point you mentioned
Meanwhile while working on the problem I have come up with the two solutions
My Date is in the format YYYY-MM-DD and I want to convert it to the format in one of the requirement as only YYYY and in the other requirement as only MM
First Solution goes like this
1. Substrings( Oconv(Input_Date,"D"),6,2) --for Month
2. Substrings( Oconv(Input_Date,"D"),1,4) -- For YEAR
And the Second solution is by using the Transform Built-in Sdk function
1. DateYearFirstGetYear(Input_Date) -- (For YEAR)
2. DateYearFirstGetMonth(Input_Date) -- (For Month)
And With Marios Hint I have got the third solution as
1. Oconv(Iconv(Data_In.DATE,"D/YMD[4,2,2]"),"DM") --For Month
2.Oconv(Iconv(Data_In.DATE,"D/YMD[4,2,2]"),"DM") -- For Year
Thanks Mario for your inputs as welll
Further Mario ,I request you to please provide me the link for Server Job Developer's Guide which you mentioned... I tried to find the Developers guide for the Server jobs but couldn't find...
Rajendra
ETL Developer
InfoCepts
ETL Developer
InfoCepts
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
All manuals are available on your installation media, and may well have been installed on your client. Otherwise most manuals - and definitely the Server Job Developer's Guide - may be downloaded free from IBM. Just make sure you have the correct version.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.