Hi
I am getting a date in the format of mmddyy. I need to convert it to yyyy-mm-dd format. How can i achieve this?
How to convert mmddyy date format to yyyy-mm-dd
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Dates don't have formats - they are binary. So what is your source? If it is a text file, for example, you have a string but, if you have specified a data type of Date, then the import operator will convert this to binary format based on the format string specified in your record schema.
The only time you need to convert this to a different format is if you are going to export it as a string data type (for example Char or VarChar).
You also need a business rule concerning your century pivot - which century applies given that you have only a two digit year component.
The only time you need to convert this to a different format is if you are going to export it as a string data type (for example Char or VarChar).
You also need a business rule concerning your century pivot - which century applies given that you have only a two digit year component.
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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You can re-arrange (concatenate) the relevant substrings. You also need logic to add the century number according to your own (century pivot) business rules.
A less efficient approach would be to convert the source string into a date then to convert that date back to a string, with a different format specified in each case.
A less efficient approach would be to convert the source string into a date then to convert that date back to a string, with a different format specified in each case.
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.
-
- Participant
- Posts: 10
- Joined: Tue Jun 24, 2008 4:27 am
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
No it won't. It will convert the string to a binary date. That's only half way to the required solution. You're also making an assumption about the century pivot year.
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.