Combine queries and send email

Need Help again :neutral_face: .
In the below flow how can I combine all the queries & send mail in below tabular format
Also display the same on dashboard

[{"id":"e2a56fda.b415","type":"MSSQL","z":"1f149e22.43a482","mssqlCN":"898d2a6f.9fb7b8","name":"A, P, Q, OEE (all machines) - this month","query":"SELECT \nROUND((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100),2) \nAS availability,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100),2)\nAS performance,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100),2) \nAS quality,\nROUND((((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100) \n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100)\n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100))/10000),2)\nAS oee\nFROM dbo.SHIFT_DATA \nWHERE \ndatepart(mm,DATE) =month(getdate())   \nAND datepart(yyyy,DATE) =year(getdate()) \n    AND [MACHINE CODE]='M02CN001'\n    OR [MACHINE CODE]='M02CN002'\n    OR [MACHINE CODE]='M02CN003'\n    OR [MACHINE CODE]='M02CN004'\n    OR [MACHINE CODE]='M02CN005'\n    OR [MACHINE CODE]='M02CN006'\n    OR [MACHINE CODE]='M02CN007'\n    OR [MACHINE CODE]='M02CN008'\n    OR [MACHINE CODE]='M02CN009'\n    OR [MACHINE CODE]='M02CN010'\n    OR [MACHINE CODE]='M02CN011'\n    OR [MACHINE CODE]='M02CN012'\n    OR [MACHINE CODE]='M02CN013'\n    OR [MACHINE CODE]='M02HB001'\n    OR [MACHINE CODE]='M02HB002'\n    OR [MACHINE CODE]='M02HB004'\n    OR [MACHINE CODE]='M02HB006'","outField":"payload","x":480,"y":800,"wires":[["78e7f81e.b0a038","ef73ee73.bc067","25b82de6.7698b2"]]},{"id":"78e7f81e.b0a038","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":840,"wires":[]},{"id":"5a910858.f025a8","type":"inject","z":"1f149e22.43a482","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":800,"wires":[["e2a56fda.b415"]]},{"id":"ffec5e26.4b322","type":"template","z":"1f149e22.43a482","name":"mail","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Hello! This is an auto generated test mail from Node Red.\n<div>OEE for MT-2's Small Shed from '{{dates.thisMonth.start}}' to '{{dates.thisMonth.end}}' till date '{{dates.date}}' is observed to be {{payload.oee}} %</div>\n<div>where</div>\n<div>Availability = {{payload.availability}} % </div>\n<div>Performance = {{payload.performance}} % </div>\n<div>Quality = {{payload.quality}} % </div>\n\n<div>for the below mentioned machines</div>\n<div>M02CN001</div>\n<div>M02CN002</div>\n<div>M02CN003</div>\n<div>M02CN004</div>\n<div>M02CN005</div>\n<div>M02CN006</div>\n<div>M02CN007</div>\n<div>M02CN008</div>\n<div>M02CN009</div>\n<div>M02CN010</div>\n<div>M02CN011</div>\n<div>M02CN012</div>\n<div>M02CN013</div>\n<div>M02HB001</div>\n<div>M02HB002</div>\n<div>M02HB004</div>\n<div>M02HB006</div>\n\n<div> Note:- Values of A, P, Q & OEE are the cumulative calculation & not airthmetic mean/aerage.</div>","output":"str","x":910,"y":800,"wires":[["6ea0c5d4.c3eb9c","165c2392.dad82c"]]},{"id":"6ea0c5d4.c3eb9c","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1070,"y":840,"wires":[]},{"id":"d80070c2.acf75","type":"MSSQL","z":"1f149e22.43a482","mssqlCN":"898d2a6f.9fb7b8","name":"A, P, Q, OEE (all machines) - last month","query":"SELECT \nROUND((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100),2) \nAS availability,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100),2)\nAS performance,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100),2) \nAS quality,\nROUND((((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100) \n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100)\n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100))/10000),2)\nAS oee\nFROM dbo.SHIFT_DATA \nWHERE \ndatepart(mm,DATE) =month(getdate())-1   \nAND datepart(yyyy,DATE) =year(getdate()) \n    AND [MACHINE CODE]='M02CN001'\n    OR [MACHINE CODE]='M02CN002'\n    OR [MACHINE CODE]='M02CN003'\n    OR [MACHINE CODE]='M02CN004'\n    OR [MACHINE CODE]='M02CN005'\n    OR [MACHINE CODE]='M02CN006'\n    OR [MACHINE CODE]='M02CN007'\n    OR [MACHINE CODE]='M02CN008'\n    OR [MACHINE CODE]='M02CN009'\n    OR [MACHINE CODE]='M02CN010'\n    OR [MACHINE CODE]='M02CN011'\n    OR [MACHINE CODE]='M02CN012'\n    OR [MACHINE CODE]='M02CN013'\n    OR [MACHINE CODE]='M02HB001'\n    OR [MACHINE CODE]='M02HB002'\n    OR [MACHINE CODE]='M02HB004'\n    OR [MACHINE CODE]='M02HB006'","outField":"payload","x":480,"y":760,"wires":[["d405888.8b6d778","25b82de6.7698b2","a7b92f5c.8eb3c"]]},{"id":"dfc1d314.4f2a2","type":"template","z":"1f149e22.43a482","name":"mail","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Hello! This is an auto generated test mail from Node Red.\n<div>OEE for MT-2's Small Shed from '{{dates.lastMonth.start}}' to '{{dates.lastMonth.end}}' is observed to be {{payload.oee}} %</div>\n<div>where</div>\n<div>Availability = {{payload.availability}} % </div>\n<div>Performance = {{payload.performance}} % </div>\n<div>Quality = {{payload.quality}} % </div>\n\n<div>for the below mentioned machines</div>\n<div>M02CN001</div>\n<div>M02CN002</div>\n<div>M02CN003</div>\n<div>M02CN004</div>\n<div>M02CN005</div>\n<div>M02CN006</div>\n<div>M02CN007</div>\n<div>M02CN008</div>\n<div>M02CN009</div>\n<div>M02CN010</div>\n<div>M02CN011</div>\n<div>M02CN012</div>\n<div>M02CN013</div>\n<div>M02HB001</div>\n<div>M02HB002</div>\n<div>M02HB004</div>\n<div>M02HB006</div>\n\n<div> Note:- Values of A, P, Q & OEE are the cumulative calculation & not airthmetic mean/aerage.</div>","output":"str","x":910,"y":760,"wires":[["eee5566b.4ace28","a9aa510a.b50fe"]]},{"id":"8d9a3e22.cf3ac","type":"inject","z":"1f149e22.43a482","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":760,"wires":[["d80070c2.acf75"]]},{"id":"a7b92f5c.8eb3c","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":720,"wires":[]},{"id":"165c2392.dad82c","type":"function","z":"1f149e22.43a482","name":"this month","func":"msg.topic='This month MT-2 Small Shed OEE with A, P, Q';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1070,"y":800,"wires":[["346dd7b7.ff8798","9f8e292f.cb2dd8"]]},{"id":"346dd7b7.ff8798","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1270,"y":800,"wires":[]},{"id":"eee5566b.4ace28","type":"function","z":"1f149e22.43a482","name":"last month","func":"msg.topic='Last month MT-2 Small Shed OEE with A, P, Q';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1070,"y":760,"wires":[["d0fdafd.f7e8c5","9f8e292f.cb2dd8"]]},{"id":"a9aa510a.b50fe","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1070,"y":720,"wires":[]},{"id":"d0fdafd.f7e8c5","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1230,"y":760,"wires":[]},{"id":"8db9c31c.f8249","type":"MSSQL","z":"1f149e22.43a482","mssqlCN":"898d2a6f.9fb7b8","name":"A, P, Q, OEE (all machines) - Yesterday","query":"SELECT \nROUND((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100),2) \nAS Availability,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100),2)\nAS Performance,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100),2) \nAS Quality,\nROUND((((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100) \n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100)\n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100))/10000),2)\nAS OEE\nFROM dbo.SHIFT_DATA \nWHERE \n[DATE]=getdate()-1   \n\n    AND [MACHINE CODE]='M02CN001'\n    OR [MACHINE CODE]='M02CN002'\n    OR [MACHINE CODE]='M02CN003'\n    OR [MACHINE CODE]='M02CN004'\n    OR [MACHINE CODE]='M02CN005'\n    OR [MACHINE CODE]='M02CN006'\n    OR [MACHINE CODE]='M02CN007'\n    OR [MACHINE CODE]='M02CN008'\n    OR [MACHINE CODE]='M02CN009'\n    OR [MACHINE CODE]='M02CN010'\n    OR [MACHINE CODE]='M02CN011'\n    OR [MACHINE CODE]='M02CN012'\n    OR [MACHINE CODE]='M02CN013'\n    OR [MACHINE CODE]='M02HB001'\n    OR [MACHINE CODE]='M02HB002'\n    OR [MACHINE CODE]='M02HB004'\n    OR [MACHINE CODE]='M02HB006'","outField":"payload","x":480,"y":680,"wires":[["359f75b6.2e613a","9feb4988.812b58","25b82de6.7698b2"]]},{"id":"5e3b9890.b426e8","type":"inject","z":"1f149e22.43a482","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":680,"wires":[["8db9c31c.f8249"]]},{"id":"359f75b6.2e613a","type":"function","z":"1f149e22.43a482","name":"Get dates","func":"var date = new Date(), y = date.getFullYear(), m = date.getMonth();\nvar aprThisYear = new Date(y, 3, 1);\nvar marNextYear = new Date(y+1, 2, 1);\nvar aprLastYear = new Date(y - 1, 3, 1);\nvar marThisYear = new Date(y, 2, 1);\nvar firstDayOfThisMonth = new Date(y, m, 1);\nvar lastDayOfThisMonth =  new Date(y, m + 1, 0);\nvar firstDayOfLastMonth = new Date(y, m - 1, 1);\nvar lastDayOfLastMonth = new Date(y, m, 0);\nvar yesterday = new Date();\n\n\nmsg.dates = {};\n\nmsg.dates.datetime = date;\nmsg.dates.date = formatDateDDMMMYYYY(date);\nmsg.dates.yesterday = formatDateDDMMMYYYY(yesterday.setDate(yesterday.getDate()- 1));\n\nmsg.dates.thisMonth = \n{    start : formatDateDDMMMYYYY(firstDayOfThisMonth),\n    end: formatDateDDMMMYYYY(lastDayOfThisMonth),   }\n\nmsg.dates.lastMonth = \n{    start: formatDateDDMMMYYYY(firstDayOfLastMonth),\n    end: formatDateDDMMMYYYY(lastDayOfLastMonth),   }\n\nmsg.dates.thisFY = \n{   start : formatDateMMMMYYYY(aprThisYear),\n    end : formatDateMMMMYYYY(marNextYear) }\n\nmsg.dates.lastFY = \n{    start : formatDateMMMMYYYY(aprLastYear),\n      end : formatDateMMMMYYYY(marThisYear)}\n\nfunction formatDateMMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'long' }).format(d);\n    return `${mo}-${ye}`;\n}\n\nfunction formatDateDDMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);\n    let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);\n    return `${da}-${mo}-${ye}`;\n}\nmsg.payload = msg.payload[0];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":680,"wires":[["8d2d39cd.869528"]]},{"id":"8d2d39cd.869528","type":"template","z":"1f149e22.43a482","name":"mail","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Hello! This is an auto generated test mail from Node Red.\n<div>OEE for MT-2's Small Shed for yeasterday i.e. '{{dates.yesterday}}' is observed to be {{payload.oee}} %</div>\n<div>where</div>\n<div>Availability = {{payload.availability}} % </div>\n<div>Performance = {{payload.performance}} % </div>\n<div>Quality = {{payload.quality}} % </div>\n\n<div>for the below mentioned machines</div>\n<div>M02CN001</div>\n<div>M02CN002</div>\n<div>M02CN003</div>\n<div>M02CN004</div>\n<div>M02CN005</div>\n<div>M02CN006</div>\n<div>M02CN007</div>\n<div>M02CN008</div>\n<div>M02CN009</div>\n<div>M02CN010</div>\n<div>M02CN011</div>\n<div>M02CN012</div>\n<div>M02CN013</div>\n<div>M02HB001</div>\n<div>M02HB002</div>\n<div>M02HB004</div>\n<div>M02HB006</div>\n\n<div> Note:- Values of A, P, Q & OEE are the cumulative calculation & not airthmetic mean/aerage.</div>","output":"str","x":910,"y":680,"wires":[["d6d6d6dc.f2b6d8"]]},{"id":"d6d6d6dc.f2b6d8","type":"function","z":"1f149e22.43a482","name":"yesterday","func":"msg.topic='Yesterday MT-2 Small Shed OEE with A, P, Q';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":680,"wires":[["d7a49946.706928","9f8e292f.cb2dd8"]]},{"id":"9feb4988.812b58","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":770,"y":640,"wires":[]},{"id":"d7a49946.706928","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1230,"y":680,"wires":[]},{"id":"d8f0a9ea.ae2088","type":"MSSQL","z":"1f149e22.43a482","mssqlCN":"898d2a6f.9fb7b8","name":"A, P, Q, OEE (all machines) - fiscal Year","query":"SELECT \nROUND((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100),2) \nAS availability,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100),2)\nAS performance,\nROUND(((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100),2) \nAS quality,\nROUND((((((SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT))- SUM (CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT)))/SUM (CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)))*100) \n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(COALESCE((((CAST([MACHINE SHIFT TIME (X)(Min.)] AS FLOAT)-CAST([AVAILABILITY LOSS TIME(Min.)] AS FLOAT))/(NULLIF(CAST([TOTAL STANDARD CYCLE TIME(Sec.)] AS FLOAT),0)))*60*CAST([PARTS PER CYCLE (U)] AS FLOAT)),0)))*100)\n*((SUM(CAST([OK PRODUCTION] AS FLOAT)) / SUM(CAST([TOTAL PRODUCTION] AS FLOAT)))*100))/10000),2)\nAS oee\nFROM dbo.SHIFT_DATA \nWHERE \n[DATE] = (CASE WHEN (MONTH(GETDATE())) <= 3 THEN convert(varchar(4), YEAR(GETDATE())-1) + '-' + convert(varchar(4), YEAR(GETDATE())%100)    \n          ELSE convert(varchar(4),YEAR(GETDATE()))+ '-' + convert(varchar(4),(YEAR(GETDATE())%100)+1)END)\n    AND [MACHINE CODE]='M02CN001'\n    OR [MACHINE CODE]='M02CN002'\n    OR [MACHINE CODE]='M02CN003'\n    OR [MACHINE CODE]='M02CN004'\n    OR [MACHINE CODE]='M02CN005'\n    OR [MACHINE CODE]='M02CN006'\n    OR [MACHINE CODE]='M02CN007'\n    OR [MACHINE CODE]='M02CN008'\n    OR [MACHINE CODE]='M02CN009'\n    OR [MACHINE CODE]='M02CN010'\n    OR [MACHINE CODE]='M02CN011'\n    OR [MACHINE CODE]='M02CN012'\n    OR [MACHINE CODE]='M02CN013'\n    OR [MACHINE CODE]='M02HB001'\n    OR [MACHINE CODE]='M02HB002'\n    OR [MACHINE CODE]='M02HB004'\n    OR [MACHINE CODE]='M02HB006'","outField":"payload","x":480,"y":880,"wires":[["c1322446.4294f8","25b82de6.7698b2"]]},{"id":"d405888.8b6d778","type":"function","z":"1f149e22.43a482","name":"Get dates","func":"var date = new Date(), y = date.getFullYear(), m = date.getMonth();\nvar aprThisYear = new Date(y, 3, 1);\nvar marNextYear = new Date(y+1, 2, 1);\nvar aprLastYear = new Date(y - 1, 3, 1);\nvar marThisYear = new Date(y, 2, 1);\nvar firstDayOfThisMonth = new Date(y, m, 1);\nvar lastDayOfThisMonth =  new Date(y, m + 1, 0);\nvar firstDayOfLastMonth = new Date(y, m - 1, 1);\nvar lastDayOfLastMonth = new Date(y, m, 0);\nvar yesterday = new Date();\n\n\nmsg.dates = {};\n\nmsg.dates.datetime = date;\nmsg.dates.date = formatDateDDMMMYYYY(date);\nmsg.dates.yesterday = formatDateDDMMMYYYY(yesterday.setDate(yesterday.getDate()- 1));\n\nmsg.dates.thisMonth = \n{    start : formatDateDDMMMYYYY(firstDayOfThisMonth),\n    end: formatDateDDMMMYYYY(lastDayOfThisMonth),   }\n\nmsg.dates.lastMonth = \n{    start: formatDateDDMMMYYYY(firstDayOfLastMonth),\n    end: formatDateDDMMMYYYY(lastDayOfLastMonth),   }\n\nmsg.dates.thisFY = \n{   start : formatDateMMMMYYYY(aprThisYear),\n    end : formatDateMMMMYYYY(marNextYear) }\n\nmsg.dates.lastFY = \n{    start : formatDateMMMMYYYY(aprLastYear),\n      end : formatDateMMMMYYYY(marThisYear)}\n\nfunction formatDateMMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'long' }).format(d);\n    return `${mo}-${ye}`;\n}\n\nfunction formatDateDDMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);\n    let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);\n    return `${da}-${mo}-${ye}`;\n}\nmsg.payload = msg.payload[0];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":760,"wires":[["dfc1d314.4f2a2"]]},{"id":"ef73ee73.bc067","type":"function","z":"1f149e22.43a482","name":"Get dates","func":"var date = new Date(), y = date.getFullYear(), m = date.getMonth();\nvar aprThisYear = new Date(y, 3, 1);\nvar marNextYear = new Date(y+1, 2, 1);\nvar aprLastYear = new Date(y - 1, 3, 1);\nvar marThisYear = new Date(y, 2, 1);\nvar firstDayOfThisMonth = new Date(y, m, 1);\nvar lastDayOfThisMonth =  new Date(y, m + 1, 0);\nvar firstDayOfLastMonth = new Date(y, m - 1, 1);\nvar lastDayOfLastMonth = new Date(y, m, 0);\nvar yesterday = new Date();\n\n\nmsg.dates = {};\n\nmsg.dates.datetime = date;\nmsg.dates.date = formatDateDDMMMYYYY(date);\nmsg.dates.yesterday = formatDateDDMMMYYYY(yesterday.setDate(yesterday.getDate()- 1));\n\nmsg.dates.thisMonth = \n{    start : formatDateDDMMMYYYY(firstDayOfThisMonth),\n    end: formatDateDDMMMYYYY(lastDayOfThisMonth),   }\n\nmsg.dates.lastMonth = \n{    start: formatDateDDMMMYYYY(firstDayOfLastMonth),\n    end: formatDateDDMMMYYYY(lastDayOfLastMonth),   }\n\nmsg.dates.thisFY = \n{   start : formatDateMMMMYYYY(aprThisYear),\n    end : formatDateMMMMYYYY(marNextYear) }\n\nmsg.dates.lastFY = \n{    start : formatDateMMMMYYYY(aprLastYear),\n      end : formatDateMMMMYYYY(marThisYear)}\n\nfunction formatDateMMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'long' }).format(d);\n    return `${mo}-${ye}`;\n}\n\nfunction formatDateDDMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);\n    let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);\n    return `${da}-${mo}-${ye}`;\n}\nmsg.payload = msg.payload[0];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":800,"wires":[["ffec5e26.4b322"]]},{"id":"c1322446.4294f8","type":"function","z":"1f149e22.43a482","name":"Get dates","func":"var date = new Date(), y = date.getFullYear(), m = date.getMonth();\nvar aprThisYear = new Date(y, 3, 1);\nvar marNextYear = new Date(y+1, 2, 1);\nvar aprLastYear = new Date(y - 1, 3, 1);\nvar marThisYear = new Date(y, 2, 1);\nvar firstDayOfThisMonth = new Date(y, m, 1);\nvar lastDayOfThisMonth =  new Date(y, m + 1, 0);\nvar firstDayOfLastMonth = new Date(y, m - 1, 1);\nvar lastDayOfLastMonth = new Date(y, m, 0);\nvar yesterday = new Date();\n\n\nmsg.dates = {};\n\nmsg.dates.datetime = date;\nmsg.dates.date = formatDateDDMMMYYYY(date);\nmsg.dates.yesterday = formatDateDDMMMYYYY(yesterday.setDate(yesterday.getDate()- 1));\n\nmsg.dates.thisMonth = \n{    start : formatDateDDMMMYYYY(firstDayOfThisMonth),\n    end: formatDateDDMMMYYYY(lastDayOfThisMonth),   }\n\nmsg.dates.lastMonth = \n{    start: formatDateDDMMMYYYY(firstDayOfLastMonth),\n    end: formatDateDDMMMYYYY(lastDayOfLastMonth),   }\n\nmsg.dates.thisFY = \n{   start : formatDateMMMMYYYY(aprThisYear),\n    end : formatDateMMMMYYYY(marNextYear) }\n\nmsg.dates.lastFY = \n{    start : formatDateMMMMYYYY(aprLastYear),\n      end : formatDateMMMMYYYY(marThisYear)}\n\nfunction formatDateMMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'long' }).format(d);\n    return `${mo}-${ye}`;\n}\n\nfunction formatDateDDMMMYYYY(d) \n{\n    let ye = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(d);\n    let mo = new Intl.DateTimeFormat('en', { month: 'short' }).format(d);\n    let da = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(d);\n    return `${da}-${mo}-${ye}`;\n}\nmsg.payload = msg.payload[0];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":760,"y":880,"wires":[["9058e4f.7fa1418"]]},{"id":"9058e4f.7fa1418","type":"template","z":"1f149e22.43a482","name":"mail","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"Hello! This is an auto generated test mail from Node Red.\n<div>OEE for MT-2's Small Shed from this fiscal year i.e. '{{dates.thisFY.start}}' to '{{dates.thisFY.end}}' till date '{{dates.date}}' is observed to be {{payload.oee}} %</div>\n<div>where</div>\n<div>Availability = {{payload.availability}} % </div>\n<div>Performance = {{payload.performance}} % </div>\n<div>Quality = {{payload.quality}} % </div>\n\n<div>for the below mentioned machines</div>\n<div>M02CN001</div>\n<div>M02CN002</div>\n<div>M02CN003</div>\n<div>M02CN004</div>\n<div>M02CN005</div>\n<div>M02CN006</div>\n<div>M02CN007</div>\n<div>M02CN008</div>\n<div>M02CN009</div>\n<div>M02CN010</div>\n<div>M02CN011</div>\n<div>M02CN012</div>\n<div>M02CN013</div>\n<div>M02HB001</div>\n<div>M02HB002</div>\n<div>M02HB004</div>\n<div>M02HB006</div>\n\n<div> Note:- Values of A, P, Q & OEE are the cumulative calculation & not airthmetic mean/aerage.</div>","output":"str","x":910,"y":880,"wires":[["7c2e0b68.b75ce4"]]},{"id":"7c2e0b68.b75ce4","type":"function","z":"1f149e22.43a482","name":"fiscal year","func":"msg.topic='fiscal year MT-2 Small Shed OEE with A, P, Q';\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1060,"y":880,"wires":[["3ccd7b09.dde404","9f8e292f.cb2dd8"]]},{"id":"913e43c8.9aba8","type":"inject","z":"1f149e22.43a482","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":240,"y":880,"wires":[["d8f0a9ea.ae2088"]]},{"id":"3ccd7b09.dde404","type":"debug","z":"1f149e22.43a482","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1230,"y":880,"wires":[]},{"id":"25b82de6.7698b2","type":"ui_table","z":"1f149e22.43a482","group":"e80abef3.57723","name":"","order":8,"width":0,"height":0,"columns":[],"outputs":0,"cts":false,"x":810,"y":940,"wires":[]},{"id":"9f8e292f.cb2dd8","type":"e-mail","z":"1f149e22.43a482","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"","x":1450,"y":820,"wires":[]},{"id":"898d2a6f.9fb7b8","type":"MSSQL-CN","tdsVersion":"7_3_B","name":"MT02","server":"192.168.21.169\\SCADASQL","port":"1433","encyption":false,"database":"MT02","useUTC":true,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5"},{"id":"e80abef3.57723","type":"ui_group","name":"Group 2","tab":"b7865f4e.298fc","order":2,"disp":true,"width":11},{"id":"b7865f4e.298fc","type":"ui_tab","name":"new test","icon":"dashboard","order":15,"disabled":false,"hidden":false}]

Hi @sahsha, for different questions, please start a new forum topic.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.