IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#57736 - 11/06/20 11:51 AM condition or a function to comparing dates
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
Hi, I'm getting the wrong result from the date conditions in my form.

occasionally my code merges the wrong images and I think I need a better code to reflect the right dates and attached the right terms.

I'm checking the dates and according the dates the right Term should be merged to the documents, but it's failing now. I have many several dates that requires different Terms and Conditions.

I have created 6 condition one for each date, for example this one should merge the term effective 01/08/2017 +

Condition Name: "Eng_Effective_Aug_1_2017_and_after"
for this record date is = 28/06/2017

=((@(93,7,10)>'2016') or ((@(93,7,10)='2017') and (@(93,4,5)>'07')) or (((@(93,7,10)='2017') and ((@(93,4,5)='08') and ((@(93,1,2)>'01') or (@(93,1,2)='01'))))))

This condition should be False but it's showing True!

Is there any better way or a function to compare different dates via PressTalk or in a condition?

Thank you for your help.
_________________________
Peace

Top
#57737 - 11/06/20 11:59 AM Re: condition or a function to comparing dates [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
You can't compare two string @(93,7,10), '2016' and expect them to know that they are actually numbers. This is PressTalk, not Javascript wink.

Try it like this:
=(strtoint((@(93,7,10))>2016) or (strtoint((@(93,7,10))=2017) and (strtoint(@(93,4,5))>7)) or (((@(93,7,10)='2017') and ((@(93,4,5)='08') and ((strtoint(@(93,1,2))>1) or (@(93,1,2)='01'))))))

The "=" will do it but not "<" nor ">"
On another note, there will be a comparison if you use "<" or ">" with strings but not a numerical one.


Edited by Jean-Cédric (11/06/20 12:04 PM)
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57738 - 11/06/20 12:57 PM Re: condition or a function to comparing dates [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
I still have Type/Syntax() "((@(93,7,10)>'2016')"

I tried to add or remove some brackets () but it's not helping
_________________________
Peace

Top
#57739 - 11/06/20 01:04 PM Re: condition or a function to comparing dates [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
by bad...try this:
=((strtoint(@(93,7,10))>2016) or ((@(93,7,10)='2017') and (strtoint(@(93,4,5))>7)) or (((@(93,7,10)='2017') and ((@(93,4,5)='08') and ((strtoint(@(93,1,2))>1) or (@(93,1,2)='01'))))))
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57740 - 11/06/20 01:32 PM Re: condition or a function to comparing dates [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
Jean, there's no syntax error smile but the result is the same as what I initially got!

Aug_1_2017_and_after is my condition

Date is reading 28/06/2017 , I want to apply any date after August 1st 2017 and data is before August so it should be false, but it's showing true! any thoughts?
_________________________
Peace

Top
#57742 - 11/06/20 03:18 PM Re: condition or a function to comparing dates [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Right at first, you check if it is bigger than 2016...it is..os it is true.
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57743 - 11/06/20 03:41 PM Re: condition or a function to comparing dates [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
I"m confused, so I split to see the result

=((strtoint(@(93,7,10))>2016) YES it's 2017
or ((@(93,7,10)='2017')

and (strtoint(@(93,4,5)) > 7)) NO it's 06
or (((@(93,7,10)='2017') YES

and ((@(93,4,5)='08') and ((strtoint(@(93,1,2)) > 1) NO

or (@(93,1,2)='01')))))) NO

result should be false!

28/06/2017 is not bigger then 01/08/2017!
_________________________
Peace

Top
#57746 - 11/09/20 10:15 AM Re: condition or a function to comparing dates [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Let's review this for date 28/06/2017:

((strtoint(@(93,7,10))>2016) or ((@(93,7,10)='2017') and (strtoint(@(93,4,5))>7)) or (((@(93,7,10)='2017') and ((@(93,4,5)='08') and ((strtoint(@(93,1,2))>1) or (@(93,1,2)='01'))))))
( TRUE or ( TRUE and FALSE ) or (( TRUE and ( FALSE and ( TRUE or FALSE )))))
( TRUE or ( TRUE ) or (( TRUE and ( FALSE and ( TRUE )))))
( TRUE or ( TRUE ) or (( TRUE and ( FALSE ))))
( TRUE or ( TRUE ) or FALSE
TRUE or TRUE or FALSE
TRUE (with operator or, only 1 value need true to be true
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57747 - 11/09/20 10:23 AM Re: condition or a function to comparing dates [Re: Sami786]
Jean-Cédric Offline
OL Expert

Registered: 10/03/16
Posts: 681
Loc: Québec, Canada
Based on your condition definition:
Quote:
have created 6 condition one for each date, for example this one should merge the term effective 01/08/2017 +

Condition Name: "Eng_Effective_Aug_1_2017_and_after"


Your condition should be like this:

= (strtoint(@(93,7,10))>= 2017) and (strtoint(@93,4,5))>= 8) and (strtoint(@(93,1,2))>= 1)
_________________________
♪♫♪♫
99 frigging bugs in my code
99 frigging bugs
Take one down
Code around
127 frigging bugs in my code
♪♫♪♫

Top
#57748 - 11/09/20 11:45 AM Re: condition or a function to comparing dates [Re: Sami786]
Sami786 Offline
OL Expert

Registered: 01/29/14
Posts: 400
Loc: Home
thank you Jean, I got your point and that helped allot smile
_________________________
Peace

Top