Posted 15 Jan 2019 I need to subtract a on date and time stamp variable from another one to show how longs before the 2 date and times are equal so the operator can see how long they have to wait. Any help would be appreciated. Ken Share this post Link to post Share on other sites
Posted 15 Jan 2019 Suggest you look at CALENDAR SUBTRACT: CSUB(731) Share this post Link to post Share on other sites
Posted 16 Jan 2019 CSUB will only subtract hours minutes and seconds. Looking for a away to do date as well Share this post Link to post Share on other sites
Posted 16 Jan 2019 If you can use Structured text this should work: (*I USED THE SAME TIME STAMP VARIABLES IN THE EQUATIONS BELOW WHICH ARE JUST THE PLC CLOCK ADDRESS IN MY PROGRAM, BUT THE 1 AND 2 LINES SHOULD BE YOUR TWO DIFFERENT TIME STAMP VARIABLE SETS, YOU COULD ALSO INCLUDE THE MONTH AND YEAR IN THE SAME MANNER IF NEEDED*) UINT_DAY1:=STRING_TO_UINT(LEFT((WORD_TO_STRING(CLOCK_DD_HH)),2)); UINT_DAY2:= STRING_TO_UINT(LEFT((WORD_TO_STRING(CLOCK_DD_HH)),2));(*SUBTRACT THE TWO VALUES FOR YOUR DAYS REMAINING RESULT*) UINT_HH1:= STRING_TO_UINT(RIGHT((WORD_TO_STRING(CLOCK_DD_HH)),2)); UINT_HH2:= STRING_TO_UINT(RIGHT((WORD_TO_STRING(CLOCK_DD_HH)),2));(*SUBTRACT THE TWO VALUES FOR YOUR HOURS REMAINING RESULT*) UINT_MM1:=STRING_TO_UINT(LEFT((WORD_TO_STRING(CLOCK_MM_SS)),2)); UINT_MM2:= STRING_TO_UINT(LEFT((WORD_TO_STRING(CLOCK_MM_SS)),2));(*SUBTRACT THE TWO VALUES FOR YOUR MINUTES REMAINING RESULT*) UINT_SS1:= STRING_TO_UINT(RIGHT((WORD_TO_STRING(CLOCK_MM_SS)),2)); UINT_SS2:= STRING_TO_UINT(RIGHT((WORD_TO_STRING(CLOCK_MM_SS)),2));(*SUBTRACT THE TWO VALUES FOR YOUR SECONDS REMAINING RESULT*) I am not sure it is the best or cleanest way to do it, but it will work! Share this post Link to post Share on other sites
Posted 17 Jan 2019 Awesome Tiger Lily! Good to see you around. Share this post Link to post Share on other sites
Posted 17 Jan 2019 Thank you Jay! I just had to do the same thing for one of my projects so happy to share!! Share this post Link to post Share on other sites