Doesn't seem to be an issue with the Date field since if I set an absolute date, it works just fine. basically I'm trying to make a view of "upcoming events" where only Event Dates greater or equal to "now" show up. Looking at the query, it appears as though its just not responding to the 'now' relative date. am I missing something here?
Filters
Node: Type in Course, Event
Settings
Date: Date Content: Date (field_date) - From date >= now
query:
SELECT node.nid AS nid
FROM node node
LEFT JOIN comments comments ON node.nid = comments.nid
WHERE node.type in ('course', 'event')Thanks in advance!
Comments
Comment #1
merlinofchaos commentedComment #2
steinmb commentedHi
I have the same issue. Upgrading to date-6.x-2.x-dev (21 April) did not solve the problem. Looking at the query used I'll find that now is "2009-01-01"
Searching issues you will find several similar issues. Some claim that it is supposed to be fixed in the latest date-dev release but for me is that not the case. Pls. read http://drupal.org/node/386406
Comment #3
steinmb commentedDid some more testing, followed all the debugging steps found on the date module project page. To me this look like a serious problem, not sure where I should start looking, Date, Views or CCK? Is it date-API that provide view with relative date information? I tested my PHP installation and "strtotime("now")" is returning the correct value as far as I can see.
--
Steinmb
Comment #4
scrypter commentedI too got desparate with this problem. I have read ALL previous posts on this issue, and still believe it is a bug. I put this one line of code into the date_api_filter_handler.inc file in the date_filter() function
if ($this->value['default_date'] == 'now') $this->force_value = TRUE;just before this line:$value_parts = !is_array($this->value[$prefix]) ? array($this->value[$prefix]) : $this->value[$prefix];and it seems to fix it!Sorry I have'nt rolled a patch, this "fix" could be a really bad idea, but it got me out of a hole. Maybe it will be a clue for Karen? I was not exposing this filter. I tried the latest dev, but got other errors (foreach!) so went back to circa 30 March 09 release. BTW, Calendar is a fantastic module, thanks so much.
Comment #5
steinmb commentedThanx! Yes it look like a bug that is only partly fixed since the last changes in date-dev fixed this issue for some but not all. However your "oneliner fix" did not do it for me... I'll still have 2009-01-01. Just be sure have I tested date_now() in a page.tpl.php with:
And it is returning the correct date and format as expected. Since the code is able to find what year it is some of it have to be working right? Is it the fuction $year_range() that generate the year? I have also had a look on the format the data in the table "field_time_value" are stored in: 2009-03-04 22:00:00
I hope KarenS read this and are able to give us some pointers to solve this issue in this awesome module :)
Cheers
Steinmb
Comment #6
scrypter commentedI am assuming 'now' is all lower case. Should really be strtoupper($this->value['default_date']) == 'NOW'. Doubt that this is your problem though. Because the preview shows the sql generated and the WHERE clause is perfect if you enter today's date (2009-04-27) and missing if you use 'now', I think the problem is in the sql generator, date_api_sql.inc and/or date_api_filter_handler.inc. I spent hours putting in print_r();die; all over the place to debug before arriving at the "fix". A lot of the comments on the same issue say it works if the filter is exposed, which sort of confirms I am possibly on the right track? If you use preview, do you see the sql? It sounds like the WHERE clause is there for you with the 2009-01-01 date. For me, it was completely absent.
Comment #7
steinmb commentedI needed to take a step back and sum up the result of the last 24 hours of debugging. And this is the result of me not working at 4am. Views, CCK, Calendar are all running stable releases.
If you create the date filter and leave "Date default:" field empty you will get buy running:
Date 6.x-2.1
6.x-2.x-dev 2009-Apr-21
Entering 'now' into "Date default:" you will get with:
Date 6.x-2.1
6.x-2.x-dev 2009-Apr-21
It is working on the last dev. release but if you omit entering 'now' the system by magic uses 2009-01-01. Is this as designed?
--
Steinmb
http://smbjorklund.com
Comment #8
sahuni commentedIt's working for english version but not for translated version.
I tested french and English.
Comment #9
ksc commentedI´m not quite sure if it´s the same issue.
In VIEWS/filters the select list (or whatever should show up) for "Relative value" doesn´t show up.
I need to set up a view "Is greater than now"
I tested with 6.x-2.1 and 6.x-2.x-dev (2009-apr-21)
Comment #10
seancorrales commentedHad the same problem as reported - using "now" did not put an entry into the SQL or limit the results. I was using the latest stable release but grabbed the latest DEV version (per #7's recommendations) and that fixed the issue.
Comment #11
steinmb commentedUnable to reproduce the problem in #8. Enabled Norwegian and English but the view was still working. Verify that 'now' are still present after changing the site language.
--
Steinmb
Comment #12
steinmb commentedHi
#9 Did you enter 'now' into Date default-form? What is the query output for the display you have created?
Comment #13
ksc commentedThat was my fault. I thought there is a select list to chose from.
I have got the point. It works fine. Thanks!
Comment #14
bluemuse commentedI have the same problem even with the latest dev version.
Past Events set to display From Date < = now. It shows all events.
Upcoming Events page set to display To Date > = now. It shows all events.
The absolute date field works, but we don't want to have to do this manually.
Comment #15
steinmb commented@blue_muse: How does the query look that Views created?
Comment #16
bluemuse commentedIf I put 'now' in the Date default field, and leave the drop downs as is:
If I use the drop downs to set the date to May 1, 2009 and skip the Date default field:
Comment #17
sahuni commentedNow it's ok for me, same in English and French, with 6.2.dev.
I had to delete filter and rebuild it for french version which was existing before. Now, when filtering, I can choose date(node), then my CCK date field.
So no issues on my part. Thanks for considering my request.
All the best
Comment #18
steinmb commented@blue_muse: What PHP release are you running? Remember to flush the view cache. Also try following the troubleshooting steps on the Date module project page.
Comment #19
bluemuse commented@steinmb Thanks for following up with me. PHP Version 5.2.6, I flushed the views cache and tried the whole list on the troubleshooting section of the Date page (just did this again to be certain). I'm still getting the following query when I use <=now for the From Date.
I post it in full here in case there's something else in the view that is causing this problem:
Comment #20
bluemuse commenteddouble post.
Comment #21
karens commentedThis is a duplicate of #432368: Problems with exposed date filter, which I'm unable to reproduce in the latest -dev code. If you have problems in the latest -dev code, follow up on that issue.
Comment #22
derEremit commentedthis is fixed for me with latest -dev
problem appears in 2.1
Comment #23
bluemuse commented@KarenS Thanks for the info. I'm going to go through everything again to make sure I'm not missing something. When I've finished, I'll post anything I find to #432368
Oh, and thanks for the great module. It works great except for this one instance.
Comment #24
WildKitten commented@scrypter #4
Thank you mate! This fixed my problem.