Hello DS Experts! I'm trying to convert a date that is in a string datatype to a date datatype in a Modify stage, but am running into problems. The format of the string date value is different from the default format of "%yyyy-%mm-%dd", so I can't just use the "date_from_string(field_name)" specification.
Input string date value: 04/20/2007
Expected output value in date datatype: 04-20-2007
I tried using the following specification as specified in the Parallel Job Developer's Guide, but I keep receiving errors:
initial_date = date_from_string(initial_date) ["%mm-%dd-%yyyy"]
Please help me. Thank you.
Jessica
Modify date that in string format to date format
Moderators: chulett, rschirm, roy
Thanks for responding! One of the problems I am having is knowing how to correctly specify the date format within the function. I have tried all variations, but each time DS throws a parsing error. Here is an example of one my specifications.
The specification is what I have entered in the Modify stage: Initial_Date=date_from_string (Initial_Date) [%mm/%dd/%yyyy]
The error I receive is the following:
main_program: Error parsing modify adapter: Expected ';' or end, got: "["; input:
Initial_Date=date_from_string (Initial_Date) [%mm/%dd/%yyyy];
Any ideas on what is the correct format to specify for the date format?
Thanks again,
Jessica
The specification is what I have entered in the Modify stage: Initial_Date=date_from_string (Initial_Date) [%mm/%dd/%yyyy]
The error I receive is the following:
main_program: Error parsing modify adapter: Expected ';' or end, got: "["; input:
Initial_Date=date_from_string (Initial_Date) [%mm/%dd/%yyyy];
Any ideas on what is the correct format to specify for the date format?
Thanks again,
Jessica
Your specification is wrong. Provide the following
And if your loading to a flat file, in the sequential file stage, go to "Format" tab, under "Type Defaults", go to the "Date" folder and enter %mm-%dd-%yyyy for "Format String"
Code: Select all
initial_date:date = date_from_string [%mm/%dd/%yyyy] (initial_date)
And if your loading to a flat file, in the sequential file stage, go to "Format" tab, under "Type Defaults", go to the "Date" folder and enter %mm-%dd-%yyyy for "Format String"
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
ray.wurlod
- Participant
- Posts: 54595
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
In case you missed it, the part in square brackets goes ahead of the part in parentheses. The part in square brackets is the format string, the part in parentheses is the input column name.
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.
