Program time

User avatar
RodGarrett
Nikon
Nikon
Posts: 8
Joined: Thu Feb 24, 2011 7:42 pm

Re: Program time

Post by RodGarrett » Fri May 20, 2016 9:44 am

I changed the script in the following way and it works fine now.

hms = IntHrs & " :" & IntMin & " :" & IntSec & " "

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Program time

Post by CrashN8 » Thu Apr 12, 2018 3:01 pm

Huge Update for this...

I've created an Excel spreadsheet that collects a time-stamp and run duration entry for each program execution. You will need to add three lines to each CMM-Manager program in order to use this Excel report. You could simply use the attached CMM-Manager program as a template.

NOTE: You should delete the lines that set toDate and fromDate depending on what version of CMM-Manager you use. See comments in Script below. I've added fromDate2 variable for version 3.8 and later to deal with new Date Time Format as well.

At beginning of program as VB Script:

Code: Select all

fromDate = (Format(now, "mm-dd-yy hh:mm:ss"))    'use this for pre-3.8
fromDate = FormatDateTime(now, 3)                'use this for 3.8 and later
fromDate2 = FormatDateTime(now, 0)               'use this for 3.8 and later
Then at end of program add another VB Script:

Code: Select all

toDate = (Format(now, "mm-dd-yy hh:mm:ss"))    'use this for pre-3.8
toDate = FormatDateTime(now, 3)                'use this for 3.8 and later
MyDiff = DateDiff("s",fromDate,toDate)

IntHrs = Int(MyDiff / 3600)
Hrs = MyDiff / 3600
IntMin = Int((Hrs - IntHrs) * 60)
Min = (Hrs - IntHrs) * 60
IntSec = Int((Min - IntMin) * 60)

hmsRpt = IntHrs & " Hrs: " & IntMin & " Min: " & IntSec & " Sec"
hms = IntHrs & ":" & IntMin & ":" & IntSec

MsgBox("Date: " & fromDate2 & Chr(10) & "Program time: " & hms)
Finally, add a DDE operation like this - notice the variable name from VB Script is used for DDE output:
DDE_utilization_report.jpg
See next image... CMM-Manager data is written to area highlighted in Orange. User can choose number of hours per shift / day in Green area. Choose number of Days, Weeks, Months, etc from area in Blue. Choose Custom drop-down option and then create custom date range in Purple area.
DDE_utilization_report_Excel.jpg
Enjoy:)
You do not have the required permissions to view the files attached to this post.

butterstone84
Participant
Participant
Posts: 6
Joined: Tue Dec 17, 2019 10:57 am

Re: Program time

Post by butterstone84 » Tue Dec 17, 2019 2:09 pm

tried implementing and was getting error with the script.

Statement: "fromDate = (Format(now, "mm-dd-yy hh:mm:ss"))'

CscriptEditor2. PerformRunScript: ScriptRun (Smisc="error on line 2 at character position 0. " .sopoindex="003". Sstaement="fromDate = (Format(now, "mm-dd-yy hh:mm:ss"))'


. did not know how to upload a picture- would have been much easier

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Program time

Post by CrashN8 » Mon Jan 27, 2020 11:18 am

butterstone84 wrote:
Tue Dec 17, 2019 2:09 pm
tried implementing and was getting error with the script.

Statement: "fromDate = (Format(now, "mm-dd-yy hh:mm:ss"))'

CscriptEditor2. PerformRunScript: ScriptRun (Smisc="error on line 2 at character position 0. " .sopoindex="003". Sstaement="fromDate = (Format(now, "mm-dd-yy hh:mm:ss"))'
I've updated the script in main post above... You should set toDate and fromDate differently starting with CMM-Manager 3.8 and later:

Code: Select all

fromDate = FormatDateTime(now, 3)                'use this for 3.8 and later

butterstone84
Participant
Participant
Posts: 6
Joined: Tue Dec 17, 2019 10:57 am

Re: Program time

Post by butterstone84 » Fri Jan 31, 2020 9:54 am

thank you, this has been very helpful.

do you know if it would be possible to add the program name to the excel spread sheet?

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Program time

Post by CrashN8 » Fri Jan 31, 2020 11:44 am

Same as above... Just add a String output for Customer Data DDE and type a Program Name. See image...

DDE_Program_Name.jpg
You do not have the required permissions to view the files attached to this post.

butterstone84
Participant
Participant
Posts: 6
Joined: Tue Dec 17, 2019 10:57 am

Re: Program time

Post by butterstone84 » Tue Feb 04, 2020 10:08 am

thank you so much for the help- one last request and hopefully I drop the topic- Im only seeing what appears to be what time the program started and the duration. I do not have the date- I tried fudging around with the formatting in excel and I don't think its helping.

thanks again for all of your help

User avatar
CrashN8
Site Admin
Site Admin
Posts: 583
Joined: Thu Feb 09, 2017 4:07 pm

Re: Program time

Post by CrashN8 » Tue Feb 04, 2020 11:05 am

butterstone84 wrote:
Tue Feb 04, 2020 10:08 am
thank you so much for the help- one last request and hopefully I drop the topic- Im only seeing what appears to be what time the program started and the duration. I do not have the date- I tried fudging around with the formatting in excel and I don't think its helping.
Yes... this FormatDateTime() difference in pre-3.8 and 3.8+ is killing me. Go back to main updated post and you will see some changes I've just made to correct this. Mainly adding a second variable fromDate2 to accommodate now() in both Date and Time formats. There might be a cleaner way but this seems to do the trick.

butterstone84
Participant
Participant
Posts: 6
Joined: Tue Dec 17, 2019 10:57 am

Re: Program time

Post by butterstone84 » Tue Feb 04, 2020 2:17 pm

well I appreciate the effort---- soo.... I put that new line in and I got a cool little dialogue box. but it did not translate to Excel through DDE - was I supposed to add a new line?

butterstone84
Participant
Participant
Posts: 6
Joined: Tue Dec 17, 2019 10:57 am

Re: Program time

Post by butterstone84 » Tue Feb 04, 2020 2:21 pm

ok I added fromDate2- variable to 11,4. and this works once I format the excel cell correctly. I still ge the little box, but I can live with this. that's for the effort

Post Reply