Increasing every hours in each iteration using for loop in thingworx.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Increasing every hours in each iteration using for loop in thingworx.
Solved! Go to Solution.
- Labels:
-
Analytics
-
Best Practices
-
Coding
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You can use below script to increase startime & endtime by 1 hour
let startTime = new Date();
// End Time plus 1 hour from startTime
let endTime = dateAddHours(startTime, 1);
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(TestDS1)
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "TestDS1"
});
// Iterate
let i = 0;
while (i < 5) {
/*
LOGICS
*/
result.AddRow({
"StartDate": startTime,
"EndDate": endTime
});
// StartTime & EndTime will increase at end of iteration
startTime = endTime;
endTime = dateAddHours(startTime, 1);
i++;
}
Output :
/VR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Hrishabh.Sharma ,
If you observe any the vast majority of the requests for help in this forum, you will observe that they follow a specific structure, where the user explains what they want to do and what the issue is.
Would you be able to explain what are you trying to achieve and where exactly you encountered issues?
I observed you posted just the code in the section where you should explain these things I mentioned above, and also the title does not clarify these as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @VladimirRosu,
Most of things, i have posted just for future reference to itself and others, I am not asking to anybody for answers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You can use below script to increase startime & endtime by 1 hour
let startTime = new Date();
// End Time plus 1 hour from startTime
let endTime = dateAddHours(startTime, 1);
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(TestDS1)
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
infoTableName: "InfoTable",
dataShapeName: "TestDS1"
});
// Iterate
let i = 0;
while (i < 5) {
/*
LOGICS
*/
result.AddRow({
"StartDate": startTime,
"EndDate": endTime
});
// StartTime & EndTime will increase at end of iteration
startTime = endTime;
endTime = dateAddHours(startTime, 1);
i++;
}
Output :
/VR
