Posted: Tue Oct 03, 2017 4:49 pm Post subject: Date Conversion thru SORT OCTOBER 02 2017 to 10/02/2017
Hi,
I need to convert an date format from OCTOBER 02 2017 to 10/02/2017 and similar for all months. datefield starts at 89 position of the file, have written the below logic and it works fine , but I have to hard-code 12 times for each month since position of the date and year would differ, is there better way to achieve this.
Joined: 26 Nov 2002 Posts: 12358 Topics: 75 Location: San Jose
Posted: Tue Oct 03, 2017 8:02 pm Post subject: Re: Date Conversion thru SORT OCTOBER 02 2017 to 10/02/2017
Suchay wrote:
Hi,
I need to convert an date format from OCTOBER 02 2017 to 10/02/2017 and similar for all months. datefield starts at 89 position of the file, have written the below logic and it works fine , but I have to hard-code 12 times for each month since position of the date and year would differ, is there better way to achieve this.
Are you sure you are getting the right results? Your INIT statement is building the record and you don't have the date field and your check for position 89 would fail as the date field is no longer in the record.
You need to parse the date before and then build it. something like this untested code
Are you sure you are getting the right results? Your INIT statement is building the record and you don't have the date field and your check for position 89 would fail as the date field is no longer in the record.
Joined: 26 Nov 2002 Posts: 12358 Topics: 75 Location: San Jose
Posted: Sun Oct 08, 2017 5:04 am Post subject:
Suchay wrote:
It worked since I overplayed after the build.
Nope It will NOT. Since you overlaid the contents AFTER the build , the position 89 will have the contents from position 150 according to your build. Unless your initial description is wrong that your date field starts at position 89, there is no way that would have worked. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Nope It will NOT. Since you overlaid the contents AFTER the build , the position 89 will have the contents from position 150 according to your build. Unless your initial description is wrong that your date field starts at position 89, there is no way that would have worked.
Position 150 has the date field and I have moved to position 89 using build, used the date in position 89 and converted,tested even today and It worked. if u want to test my logic I will send my input file and sort card you can test it out.
Joined: 26 Nov 2002 Posts: 12358 Topics: 75 Location: San Jose
Posted: Tue Oct 10, 2017 1:10 am Post subject:
Suchay wrote:
Quote:
Nope It will NOT. Since you overlaid the contents AFTER the build , the position 89 will have the contents from position 150 according to your build. Unless your initial description is wrong that your date field starts at position 89, there is no way that would have worked.
Position 150 has the date field and I have moved to position 89 using build, used the date in position 89 and converted,tested even today and It worked. if u want to test my logic I will send my input file and sort card you can test it out.
I don't need your input file you simply are referring to the date field after your BUILD which is incorrect way of describing the requirements. Your initial description mentioned this
Suchay wrote:
datefield starts at 89 position of the file, have written the below logic and it works fine , but I have to hard-code 12 times for each month since position of the date and year would differ, is there better way to achieve this.
So be clear on your requirements. I wrote the parse statement based on your description. You need to change the ABSPOS value to 150 instead of 89. _________________ Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum