Jump to content

Select empty or date greater than …


suntrop
 Share

Recommended Posts

I added a field login_end to the user template, where I can set an end date until the account is valid. Only the minority of user have this field set (to a date in the past or future). Other users have an empty login_end.

Now I need to select all users with an empty login_end field and those with a date in the future. But I am afraid it isn't possible with the selector engine of PW. 

// Won't work, because "," translates in SQL to "AND"
template=user, login_end>=today, login_end=
// won't work either
template=user, login_end>=today|

Next … I think I have to create two PageArrays – one with empty login_end and one with login_end >=today. And import the second one into the first PageArray with ->import($secondPageArray). But that wold make my code a lot more complicated, because I need this query 5 times in my module and other selector parts are based on variables. So I would be much happier if there would be a solution to get them all within one query.

Hope someone can help :-)

Link to comment
Share on other sites

From what I understand, OR-groups are not needed here, since we only want to OR two values in the same field. Selecting login_end=1406930400|1416524400 works, so why doesn’t login_end=0|1416524400? 0 on its own matches empty datetime fields. The SQL error is "not unique table/alias", so that looks more like a bug.

LostKobrakai’s solution is the best anyway, though.

  • Like 1
Link to comment
Share on other sites

Seems I am a little bit early :-) Thanks for the info!

Doesn't "template=user, !login_end<=today" work?

This looks like it is working, at least I am getting the correct amount with count() so I think it is what I have been looking for. Didn't know about the negation. I thought only != is working.

Thanks to both of you!! That helped a lot

Selecting login_end=1406930400|1416524400 works

I need to check if it is blank or less/greater than. The less/greater is the 'problem' here I think. Anyhow, thanks for helping.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...