BAQ Help-Apply expression in Table Criteria

Major brain fart here, but how do I apply an expression to a table critera?

I need to do this basic SQL but in a BAQ:

select count(*)
from UD100A
where Character01 = 'Deallocated'
and Convert(datetime, ChildKey1) >= GETDATE()-1

And I can’t for the life of me think of how to apply the second part, the Convert(datetime, ChildKey1) to the BAQ editor as I can only select the field, give it an operation, and then have options for filter values

#Hack

Just make sure the left side is always “Truth” AND

Works
image

2 Likes

Ok I wasn’t sure if it would handle the datatypes well but it appears to be ok with just setting the expression like that
In this case ChildKey1 is a string that is storing a datetime, but seems a little error prone without the ability to set the lefthand side of the equation :man_shrugging:

No no cast ChildKey otherwise you’ll get all sorts of weird ish

Look back at my example I made the first part of the expression true then I added in a conversion and comparison using integer.

So in your case you could do

Company = ‘YourCompany’ AND Convert(ChildKey, Date) > GetDate()-1 or something like that

It’s basically SQL Injection (of sorts)

Ahh yes ok I’ll do that. good call, thanks

Oh Damn. JCSE.

(Jose Short Circuit Evaluation)

I’m fond of this one I also like adding
OR 1 = 1 when I want to by pass a check temporarily without messing up the existing criteria (While developing)

1 Like

Well crud, I wonder if they “fixed” this on 10.2.600?

image

Hmm did they? (Checking my instance)

Can you hit analyze?

I’m willing to bet if you hit Analyze the error will be “Possible SQL Injection”. There was an update they put in to fix it recently (10.2.500 or 600?).

Analyze gives “Syntax is OK”

Does that query run in SQL (as typed)?

Looks like no
Might need to check out my data conversion here…
Ugh I’m an idiot hold on, did the wrong field…

Ok works fine when you select the proper field :sweat_smile:

Got it, ID10T error happens to all of us daily! Someone should fix that bug LoL

Glad Epicor didn’t fix this hack… its awesome and they should leave it alone… Nobody tell them!

3 Likes

I should walk away from computers today