Query using Date.Since Token

Topics: General
Apr 8, 2012 at 5:26 PM

Successfully got Orchard 1.4 up and running - it is fantastic.

So, no dramas there but a fancy 'however'...

I've created a new query that I need to filter on a set of content types (done) and where their date field is a date greater than or equal to today, i.e. in the future.  I'm getting bizarre results returned, sometimes duplicates in the list too.  Ran out of ideas and I'm probably being a right biff but I can't see how to set a filter for a date only in the future?

Any help would be marvellous.  Thanks in advance.

Apr 8, 2012 at 7:17 PM
Edited Apr 8, 2012 at 7:17 PM

Greater than or equal to {Date}

Apr 8, 2012 at 9:46 PM
JLedel wrote:

Greater than or equal to {Date}

Thanks JLedel, I hadn't tried that token, but the result was the same - it return in preview duplicates.  I've only got three entries, with one set for the 16/02/12, the other two set for 30/04/12.  Using a Greater than or equal to {Date} returns 5 in total.  The future dates are duplicated bizarrely.  

The Content Type uses a date time field that has a date select control that unfortunately uses US formatted dates, i.e. MM/DD/YYYY.  I keep having to change the entry as validation kicks in and asks to enter a valid date.  Do you think that could have something to do with this headache? 

Apr 9, 2012 at 3:18 PM

Maybe I am just not reading this right, but I always use the date offset for querying based on today's date, so I can say greater than or equal to the offset 0 days. And that has always worked for me, even with some dates I have that appear in different formats.

Apr 9, 2012 at 3:51 PM
reverand wrote:

Maybe I am just not reading this right, but I always use the date offset for querying based on today's date, so I can say greater than or equal to the offset 0 days. And that has always worked for me, even with some dates I have that appear in different formats.

Reverand, many thanks.  I hadn't thought of that, but I think that has sorted it - Brilliant!  I certainly haven't got duplicates and the older event is no longer in the results set returned.  

Thought that had cracked it, but I can include any field I wish to as a property in a customised Html list.  Works fine until I include the date field I've added to the Content Type I created, at which point it returns no results.  Set it back to the default Summary display and it all works fine.  This is driving me insane - I must be doing something wrong - is it localisation that could be causing a problem (en-GB) or the SQL Server setting with my hosting provider in the UK? 

Apr 9, 2012 at 4:24 PM

OK so it works with the default Summary template but not with a customized one, or it works in Summary but not in Detail?

If changing templates solves it then your problem is there.

Apr 9, 2012 at 4:27 PM

If thats not it, you may also want to try the {Date.Format:DD/MM/YYYY} token. 

Apr 9, 2012 at 4:53 PM
reverand wrote:

OK so it works with the default Summary template but not with a customized one, or it works in Summary but not in Detail?

If changing templates solves it then your problem is there.

Cheers Reverand, sorry for the confusion.  I'm using the standard or default layout under a query and it works fine, the Date Time Field in question is displayed as entered.  But when I change to a different layout using Properties to create a Simple list for example, and add the same Date Time Field into the list (no other customisation, just a shorter list of properties from the Content Type), the Projection doesn't work whether as a Widget or as a straightforward 'page'.  Does that make sense?

Apr 9, 2012 at 7:12 PM

AH I get it, it works in the standard Layout but not in another. I get it now. Hmmmmmm