I have a date(YYYYMMDD) in a number format.
For example:
- 20050810 become 50810
- 20150810 become 150810
I have to insert this number in a oracle table where the field is a date.
I'm using Iconv(DATE, "DYMD[2,2,2]") but doesn't working.
Does anybody help me?
Regards,
Fernando
Iconv
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 142
- Joined: Wed Mar 24, 2004 10:51 am
- Location: Brazil
-
- Participant
- Posts: 232
- Joined: Sat May 07, 2005 2:49 pm
- Location: USA
Hi Fernando,
The solution has already been mentioned several times in this forum. Please use the search facility.
Any Date Conversion has two go through two steps
1) First it has to be converted into the required format using Iconv, which will give the output in the internal format. This internal format is not suitable to be directly inserted into the target database.
2) Therefore you need to use Oconv on the result of the Iconv, to convert it into the correct required format and this value can be directly inserted into the database table.
You can combine both the above steps like shown below
The solution has already been mentioned several times in this forum. Please use the search facility.
Any Date Conversion has two go through two steps
1) First it has to be converted into the required format using Iconv, which will give the output in the internal format. This internal format is not suitable to be directly inserted into the target database.
2) Therefore you need to use Oconv on the result of the Iconv, to convert it into the correct required format and this value can be directly inserted into the database table.
You can combine both the above steps like shown below
Code: Select all
Oconv(Iconv(InLink.InDate,"DYMD[2,2,2]"),"DYMD[2,2,2]")
Thanks,
Naveen
Naveen
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
If it's in YYYYMMDD format, then you need either [4,2,2] (not [2,2,2] which specifies a two-digit year) or nothing after the DYMD part of your Iconv() specification.
Both of the following will work for YYYYMMDD format:
However, since there are not data types in DataStage server edition, you may as well just treat the incoming date as a string and format it appropriately (provided you're certain that all incoming values are valid). For example:
Both of the following will work for YYYYMMDD format:
- Iconv(TheDate, "DYMD[4,2,2]")
Iconv(TheDate, "DYMD")
However, since there are not data types in DataStage server edition, you may as well just treat the incoming date as a string and format it appropriately (provided you're certain that all incoming values are valid). For example:
- Fmt(TheDate, "L####-##-##")
TheDate[1,4] : "-" : TheDate[5,2]: "-" : TheDate[7,2]
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.