I've almost got a dataport working here for my EDI feed, but I'm having trouble parsing the date.
Starting at position 13, and extending for 8 characters, there is a date field in the file with a format of 'YYYYMMDD'.
I have tried to use the following syntax to extract the date, but the result I'm getting is ValidDemandDate (global variable) is FALSE.
Can anyone troubleshoot this one line for me?
ValidDemandDate := EVALUATE(DemandDate,COPYSTR(EDIRecord.RecordData,13,8));
Comments
One thing is sure. EVALUATE expect dates in the format set in your Territorial and Local Settings in Windows. I think it will be the reason.
Is there any way to use FORMAT to extract a date like this?
Oleg
try this: Where YearInt, MonthInt and DayInt are integers. I have not tested this, but I am pretty sure it'll work.
Of course you would ideally put this in a function with the MyDateString as a parameter and a date as return value.
RIS Plus, LLC
1) Set the Terrotorial Settings in Windows on that machine
2) Write a function (an ugly bunch of COPYSTR's) that creates a string that is in the same format the Territorial Settings typically expect.
FORMAT isn't useful in this case, because it works vice versa, it creates a string out of something else.
I'll do that and post the results.
I thought I could nest a format() call inside of EVALUATE() to rearrange the string before passing into the evaluate function.
Thanks! I'll you know the results.
Oleg
One tiny problem though. This code only works if datevalues are not null. That happens sometimes, so you would have to test for either Yearint, Monthint and Dayint not being null or zero. But then again, it goes without saying :whistle:
RIS Plus, LLC
IF EVALUATE(MyDate,STRSUBSTNO('%1/%2/%3',
COPYSTR(EDIRecord.RecordData,19,2),
COPYSTR(EDIRecord.RecordData,17,2),
COPYSTR(EDIRecord.RecordData,13,4)))THEN;
This will allow for an empty string as well, with the IF statement
I have not tested this bit of code but it will work!
Mobile: +44(0)7854 842801
Email: david.cox@adeptris.com
Twitter: https://twitter.com/Adeptris
Website: http://www.adeptris.com