Originally posted by: davidoff
The conversion works fine.
However, my initial point was more related to an automatic transform of a date into an int through the prepare block
I have not been able to do that straightforward. Rather, i declared in the .mod file a tuple with both a string and an int :
tuple DateInfo{ string date; int minutes;} {DateInfo} dateInfos = ...;
then , in the prepare block :
function transformDate(truc,name){
//2013-12-13 08:10:00 +0100 YYYY-MM-DD
writeln(truc);
writeln(name);
writeln("----");
//for(var rd=1;rd<=7 ;rd++){
for(var i=0;i< Opl.card(thisOplModel[name]);i++){
var record = Opl.item(thisOplModel[name],i);
var dateIn = record.date;
writeln("dateIn=",dateIn);
dateTime = dateIn.split(" ");
date = dateTime[0]; time = dateTime[1];
dateSplit = date.split("-");
dateNew = dateSplit[1]+"/"+dateSplit[2]+"/"+dateSplit[0] + " " + time;//MM/DD/YYYY
dateOut = new Date(Date.parse(dateNew));
writeln(dateNew);
var minutes = dateOut.getMinutes();
writeln("minutes=",minutes);
record.minutes = dateOut.getMinutes();
}
return true;
}
}
SheetConnection sheet("uc1.xlsx");
dateinfos from SheetRead(sheet,"starts") invoke transformDate;
You see in the code that I transform the date into minutes in order to store it in the attribute minutes of my tuples.I still wonder if there is a more elegant way to load transformed informations directly
#DecisionOptimization#OPLusingCPOptimizer