Date Discrepency in the Code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Date Discrepency in the Code

    I have a calibration program that uses the SystemDate and the ProbeData date to determine when to run the full calibration on a probe versus a shortened qualification. I subtract 2 days from the SystemDate and if the ProbeData date is earlier then 2 days ago it will run the full calibration. After some issues with a certain probe, I noticed that it has not run the full calibration since 12/30/19. Looking through our 18 probes, 4 of them are in a similar boat. The code is the same for all the probes and it has worked fine on them.

    What could be causing these probes to skip the full calibration based on date?

    Here is the code in question...

    Code:
    ASSIGN/D=(SYSTEMDATE("dd")-2)  '(Subtract 2 days from todays date)
    ASSIGN/PASTDATE=SYSTEMDATE("MM/"+D+"/yy")  '(Combine new day with month and year to make the date)
    ASSIGN/V15=PROBEDATA("date","T1A0B0","4MMBY40MM")  '(Get the date the probe was last calibrated)
    ASSIGN/V16=IF(V15<PASTDATE,"Yes","No")  '(If probe date is more then 2 days then assign as YES, otherwise NO)
    IF_GOTO/V16=="Yes",GOTO = CALIB_4BY40
       Qualification Part
    IF_GOTO/PROBEDATA("STANDARDDEVIATION","4MMBY40MM")>.0004,GOTO = NEXTPROBE
    CALIB_4BY40=LABEL/
       Full Calibration
    NEXTPROBE=LABEL/
    Thanks in advance!

  • #2
    I can see a few potential problems. PC-Dmis is doing a straight forward subtraction of one value from the other but because the values you are comparing are dates it's not that simple. For example, if it's the first day of the month, SYSTEMDATE would return 01 for the "dd" element. You then subtract 2 from it which would leave you with -1. I think you need to convert the SYSTEMDATE and the PROBEDATA dates from day/month/year format to an equivalent value in days. See below for an example of how to do it using PC-Dmis code. However, it would probably be more efficient to pass the two dates into a script, do the comparison and pass back a result. This is because most scripting languages have built in functions for converting and comparing dates.

    Code:
    ASSIGN/SYS_YEAR=(SYSTEMDATE("yy")+2000)*365       <- convert current year into equivalent days
    ASSIGN/SYS_MONTH=SYSTEMDATE("MM")                 <- get current month
    SELECT/SYS_MONTH                                  <- depending on what month it is, add number of days from previous months to current day
    CASE/1                                               (doesn't take account of leap years)
    ASSIGN/SYS_DAYS=SYS_YEAR+SYSTEMDATE("dd")
    END_CASE/
    CASE/2
    ASSIGN/SYS_DAYS=SYS_YEAR+31+SYSTEMDATE("dd")
    END_CASE/
    CASE/3
    ASSIGN/SYS_DAYS=SYS_YEAR+59+SYSTEMDATE("dd")
    END_CASE/
    CASE/4
    ASSIGN/SYS_DAYS=SYS_YEAR+90+SYSTEMDATE("dd")
    END_CASE/
    CASE/5
    ASSIGN/SYS_DAYS=SYS_YEAR+120+SYSTEMDATE("dd")
    END_CASE/
    CASE/6
    ASSIGN/SYS_DAYS=SYS_YEAR+151+SYSTEMDATE("dd")
    END_CASE/
    CASE/7
    ASSIGN/SYS_DAYS=SYS_YEAR+181+SYSTEMDATE("dd")
    END_CASE/
    CASE/8
    ASSIGN/SYS_DAYS=SYS_YEAR+212+SYSTEMDATE("dd")
    END_CASE/
    CASE/9
    ASSIGN/SYS_DAYS=SYS_YEAR+243+SYSTEMDATE("dd")
    END_CASE/
    CASE/10
    ASSIGN/SYS_DAYS=SYS_YEAR+273+SYSTEMDATE("dd")
    END_CASE/
    CASE/11
    ASSIGN/SYS_DAYS=SYS_YEAR+304+SYSTEMDATE("dd")
    END_CASE/
    CASE/12
    ASSIGN/SYS_DAYS=SYS_YEAR+334+SYSTEMDATE("dd")
    END_CASE/
    END_SELECT/
    ASSIGN/V2=PROBEDATA("date")                          <- get last calibrated date
    ASSIGN/PRB_YEAR=(ELEMENT(3,"/",V2)+2000)*365         <- convert year into equivalent days
    ASSIGN/PRB_MONTH=(ELEMENT(2,"/",V2))                 <- get month last calibrated
    SELECT/PRB_MONTH                                     <- based on month, add number of days from previous months to the day it was last calibrated
    CASE/1                                                 (doesn't allow for leap years)
    ASSIGN/PRB_DAYS=PRB_YEAR+ELEMENT(1,"/",V2)
    END_CASE/
    CASE/2
    ASSIGN/PRB_DAYS=PRB_YEAR+31+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/3
    ASSIGN/PRB_DAYS=PRB_YEAR+59+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/4
    ASSIGN/PRB_DAYS=PRB_YEAR+90+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/5
    ASSIGN/PRB_DAYS=PRB_YEAR+120+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/6
    ASSIGN/PRB_DAYS=PRB_YEAR+151+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/7
    ASSIGN/PRB_DAYS=PRB_YEAR+181+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/8
    ASSIGN/PRB_DAYS=PRB_YEAR+212+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/9
    ASSIGN/PRB_DAYS=PRB_YEAR+243+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/10
    ASSIGN/PRB_DAYS=PRB_YEAR+273+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/11
    ASSIGN/PRB_DAYS=PRB_YEAR+304+(ELEMENT(1,"/",V2))
    END_CASE/
    CASE/12
    ASSIGN/PRB_DAYS=PRB_YEAR+334+(ELEMENT(1,"/",V2))
    END_CASE/
    END_SELECT/
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    PRB_DAYS
    SYS_DAYS
    IF/PRB_DAYS<(SYS_DAYS-2)             <- compare two values (both now in total number of days format)
    COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
    "PRB LAST CALLIBRATED "+(SYS_DAYS-PRB_DAYS)+" DAYS AGO"
    END_IF/
    Neil Challinor
    PC-DMIS Product Owner

    T: +44 870 446 2667 (Hexagon UK office)
    E: [email protected]

    Comment


    • FMC.QC
      FMC.QC commented
      Editing a comment
      I assumed it was something along those lines... why do you think it works on some probes but not on others?
      I will work on scripting this.

      Thanks

    • neil.challinor
      neil.challinor commented
      Editing a comment
      Probably just luck. As long as they were calibrated in the same month and you didn't do the check on 1st or 2nd it probably worked.

Related Topics

Collapse

Working...
X