Issue with Date Conversion
Moderators: chulett, rschirm, roy
Issue with Date Conversion
Hi,
I am having an issue with conversion of string to date....
the incomming date can come in the following format
9/24/2008 or 9/9/2008 or 12/1/2008 or 12/12/2008
If i use the follwoing format
StringToDate(lnk_SRC_TRANSLATION_STAGE.EXP_DATE,"%mm/%dd/%yyyy")
I am getting the error as
Data string '9/24/2008' does not match format '%mm/%dd/%yyyy': the value for tag %mm has fewer characters than expected.
Please help...
Thanks
Sahitya
I am having an issue with conversion of string to date....
the incomming date can come in the following format
9/24/2008 or 9/9/2008 or 12/1/2008 or 12/12/2008
If i use the follwoing format
StringToDate(lnk_SRC_TRANSLATION_STAGE.EXP_DATE,"%mm/%dd/%yyyy")
I am getting the error as
Data string '9/24/2008' does not match format '%mm/%dd/%yyyy': the value for tag %mm has fewer characters than expected.
Please help...
Thanks
Sahitya
As documented within the Parallel Job Developer's Guide and discussed many times within this forum, use %d and %m to handle variable-width day and month fields.
A simple search for "date formats" within the product documentation will lead you to a table of available date and time formats.
Regards,
A simple search for "date formats" within the product documentation will lead you to a table of available date and time formats.
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.
I don't have my documentation with me and search isn't turning up what I'm looking for - there's a date format modifier that allows a portion (month, day, etc) to be 1 or 2 characters... 's' is coming to mind but it is spelled out in the docs.
James, I don't think the single letter formats handle both, pretty sure it handles just one and the magical "s" thingie I'm seeing in my head allows it to handle either size.
James, I don't think the single letter formats handle both, pretty sure it handles just one and the magical "s" thingie I'm seeing in my head allows it to handle either size.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Hi
Thank you for your responses i should have checked the documentation first....it was easy enough...i am posting the answer for those like me looking for the answer
Specify this option to allow leading spaces in date formats. The s option is specified in the form:
%(tag,s)
Where tag is the format string. For example:
%(m,s)
indicates a numeric month of year field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property:
%(d,s)/%(m,s)/%yyyy
Then the following dates would all be valid:
8/ 8/1958
08/08/1958
8/8/1958
i used the format %m%d%yyyy for my case and it works
Thanks
Thank you for your responses i should have checked the documentation first....it was easy enough...i am posting the answer for those like me looking for the answer
Specify this option to allow leading spaces in date formats. The s option is specified in the form:
%(tag,s)
Where tag is the format string. For example:
%(m,s)
indicates a numeric month of year field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property:
%(d,s)/%(m,s)/%yyyy
Then the following dates would all be valid:
8/ 8/1958
08/08/1958
8/8/1958
i used the format %m%d%yyyy for my case and it works
Thanks
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
%d matches a single digit in the date. %dd matches two digits in the date. %dd,v allows the format to be variable (one digit or two). There are other variations.
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.
-
- Premium Member
- Posts: 62
- Joined: Tue Dec 07, 2004 7:41 am
- Location: Brasil
- Contact:
Re: Issue with Date Conversion
One way to solve:
Use the Field to separate the day, month and year.
Field (column,'/', 1) for the month
Field (column,'/', 2) for the day
Field (column,'/', 3) for the year
After that, use the Str function to complete on the left of zero day and month, if necessary.
Then finally, concatenate the results.
May not be the best way, but it solves.
Use the Field to separate the day, month and year.
Field (column,'/', 1) for the month
Field (column,'/', 2) for the day
Field (column,'/', 3) for the year
After that, use the Str function to complete on the left of zero day and month, if necessary.
Then finally, concatenate the results.
May not be the best way, but it solves.