CHARS_FROM_LEFT issue?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
bwalk
Posts: 55
Joined: Thu May 10, 2018 12:10 am

CHARS_FROM_LEFT issue?

Post by bwalk »

Good Day Devs,
I think there is an issue with the CHARS_FROM_LEFT function but it could just be me.
I am looking at some time selections in the format of {hour} space {AMPM} EX: 11 AM, 12 PM, 1 PM, 2 PM
I then convert that to a string formatted like 11:00, 12:00, 13:00, 14:00 etc.
All the selections work with the exception of the 1 PM selection.
I have been trying to figure it out for several, no many hours.
Any assistance would be appreciated.
I will upload a sample BSV of the issue but here is my Rule code.
Any assistance is much appreciated.
---------------------------------
If CHARS_FROM_RIGHT(tempBO.TimeChoice,2)='AM' AND CHARS_FROM_LEFT(tempBO.TimeChoice,2)<'10' Then
tempBO.Result=CHARS_FROM_LEFT(tempBO.TimeChoice,1)+':00'
Else If CHARS_FROM_RIGHT(tempBO.TimeChoice,2)='AM' AND CHARS_FROM_LEFT(tempBO.TimeChoice,2)>='10' Then
tempBO.Result=CHARS_FROM_LEFT(tempBO.TimeChoice,2)+':00'
Else If CHARS_FROM_RIGHT(tempBO.TimeChoice,2)='PM' AND CHARS_FROM_LEFT(tempBO.TimeChoice,2)='12' Then
tempBO.Result=CHARS_FROM_LEFT(tempBO.TimeChoice,2)+':00'
Else
tempBO.Result=CHARS_FROM_LEFT(AS_STRING(AS_NUMBER(CHARS_FROM_LEFT(tempBO.TimeChoice,1))+12),2)+':00'
bwalk
Posts: 55
Joined: Thu May 10, 2018 12:10 am

Re: CHARS_FROM_LEFT issue?

Post by bwalk »

Not sure why my BSV didn't upload previously when I posted my issue but here it is again.
Attachments
CHARS_LEFT.zip
(37.38 KiB) Downloaded 530 times
intra
Posts: 279
Joined: Thu Oct 11, 2012 1:30 pm
Location: Australia

Re: CHARS_FROM_LEFT issue?

Post by intra »

Instead of having a single rule that tries to cater to all possibilities , break down the IF statement into AM and PM

So

Rule 1 - AM
Rule 2 - PM
Attachments
CHARS_LEFT1.zip
(37.67 KiB) Downloaded 507 times
Avid Linux user....
idpSteve
Posts: 201
Joined: Thu Jul 27, 2017 6:13 am
Location: Johannesburg, South Africa
Contact:

Re: CHARS_FROM_LEFT issue?

Post by idpSteve »

I second that. Having more than 3 'ELSE IF' statements seems not to work most of the time.. Separating into a few processes/rules that will do the same thing is much more reliable.
bwalk
Posts: 55
Joined: Thu May 10, 2018 12:10 am

Re: CHARS_FROM_LEFT issue?

Post by bwalk »

I will give your suggestions a go.
Thank you all so much!
Post Reply