This project is read-only.

query filter on Date not working as expected

Topics: Administration, Customizing Orchard, General
Oct 26, 2012 at 1:20 PM

in 'queries' I have a filter:

MyDate 'is greater than or equal to'     'an offset from the current time'; value set at '0' Unit 'Day'

the MyDate is set to '10/26/12' BUT on Oct 26 it does NOT bring me that ContentItem in a 'projection'.
When I set Value to '-1' I GET my ContentItem.

Am I doing something wrong?
Is it a culture issue? I used en-US and fr-FR > same problem
thanks for your time and hints

Oct 31, 2012 at 10:27 PM

Could you try and set a breakpoint in the code where comparison is executed? Perhaps it has something to do with a difference in time zone of your pc and UTC.

Nov 2, 2012 at 8:21 AM
thanks again for your time ..
my guess is, that the comparison takes place in:
projections>FilterEditors>Forms>DateTimeFormValidation.cs; I set the breakpoint on below if(.......
but it never breaks!
I also checked the 'times': Max, Min, Now, today, Utc ---> all show the correct date!
 public override void Validating(ValidatingContext context) {
            if (context.FormName == DateTimeFilterForm.FormName) {

                var isRange = new[] {"Between", "NotBetween"}.Contains(context.ValueProvider.GetValue("Operator").AttemptedValue);
                var min = context.ValueProvider.GetValue("Min");
                var max = context.ValueProvider.GetValue("Max");
                var value = context.ValueProvider.GetValue("Value");
                var valueType = context.ValueProvider.GetValue("ValueType");
Is there another location to set a breakpoint?

Nov 2, 2012 at 6:21 PM

Maybe you could check if the time injected on line 32 in Orchard.Projections.FieldTypeEditors.DateTimeFieldTypeEditor is correct (set a breakpoint there).

Nov 2, 2012 at 8:30 PM
Edited Nov 2, 2012 at 9:13 PM
thanks will investigate -- the short test still gives a correct date
Nov 4, 2012 at 9:26 AM
Edited Nov 6, 2012 at 7:15 AM
I have a suspicion why I have a problem with the query ...
first the problem I see in the DB .sdf:
Commom_CommonPartRecord shows correctly for all 3 dates 4.11.2012 08:32:55 for created, published, modifiedUTC
(same for Commom_CommonPartVersionRecord)
However in:
Orchard_Framework_ContentItemVersionRecord I see for my DateEnd
<DateEnd>2012-11-03T23:00:00.0000000Z</DateEnd> ("DateEnd" is my field name;I added it using the pop-up calendar; and its defined as 'date' only!)
My ContentItem (on user screen) also shows "4.11.2012"
Now, If Orchard compares (DateEnd>= today) with this date it would explain why in 'queries' I have to set offset "-1" !
? which record is used to do the comparison ?
? <DateEnd>2012-11-03T23:00:00.0000000Z</DateEnd>; does this mean it's the beginning of 201-11-04 ? I'm confused.
Thanks for your time and advise
Apr 24, 2013 at 2:00 PM
Is doesn't work here either.
What I did was setting "is greater or equal than" 0 Day to => "Is greater than" -1 Day

That worked for me!