I am creating an "upcoming events" view for the sidebar that just lists the next two events from my events content type (all of which are displayed in a calendar view). It works when I specify today's date as an absolute value (in conjunction with "Is Greater THan", but not when is leave the absolute fields undeclared and try to use 'now' in the relative field. Any suggestions what's wrong? Thanks!

Comments

justbradford’s picture

Hmmm. I had to go under the Filter settings and change Date Form Type for "Select" to "Text." Interesting, the way it showed up before (when it was set to "select"), in combination with the help text...looked like it would work under "select".

Great tutorial at http://www.DrupalTherapy.com on using Event content type for calendar, btw...that's what got me started...just didn't see this particular wrinkle.

lejonsson’s picture

I had similar problems. When the form type was set to "select", 'now" translated into 2009-01-01 for the filter, i.e. only the year was correct while month and date were actually missing (set to 01). I struggled with this strange behavior for a while until I saw this posting, changing the form type to text made the filter work properly by correctly translating 'now' into todays date 2009-03-23.

ianreeves’s picture

I've had the same issue but haven't resolved it.
When I put an absolute date value in to the view filter, the block displays correctly, listing items from that date.
But when I use 'now' as a relative value, the block lists items starting from the very first date it can find. I've tried changing the form type from 'select' to 'text' (and even to 'pop up' too for good measure), but it makes no difference. As soon as I put the 'now' value in, the filter disappears completely from the query, as below:

Query returned when I use an absolute date value:
...
WHERE (node.type in ('diary_date'))
AND (DATE_FORMAT(STR_TO_DATE(node_data_field_date.field_date_value, '%Y-%m-%dT%T'), '%Y-%m-%d') >= '2009-03-27')
ORDER BY node_data_field_date_field_date_value ASC

Query returned when I use the 'now' relative value:
...
WHERE node.type in ('diary_date')
ORDER BY node_data_field_date_field_date_value ASC

Anybody else have any suggestions to stop me having to remember to go and update the view every day, so that the date changes...?

ghrasko’s picture

Where do you try to enter "now"? I can not see a relative field, only the absolute one. If the type is "select", then i van not write "now" anywhere. If it is "text", I can write it to the absolute field, but it is not accepting it saying it is invalid.

I have the folowing screen:

---------

Absolute value:
[field to enter, or select]
format sample

Relative value:

Relative values will be used if no date is set above. Use 'now' to default to the current date at runtime or add modifiers like 'now +1 day'. The To date default value is used when the operator is set to 'between' or 'not between'.

---------

There is no field for the relative value.

Gabor

ghrasko’s picture

Uhh, I see I have to add the relative value "during runtime". Well, I am a beginner and I do not know how to do that. If one could help me...

I planned to add a publish_date field to my news content. Only news items where publish_date <= now should be displayed in the view.

MODIF: no, I still believe there should be a field for relative value and i have to add "now" or "now +1 day" there.

Gabor

lejonsson’s picture

The fields "Date default" and "To date default" are set below the text you refer to ("Relative values will be used if no date is set above. Use 'now' to default to the current date at runtime or add modifiers like 'now +1 day'. The To date default value is used when the operator is set to 'between' or 'not between'. If the filter is exposed, these values will be used to set the inital value of the exposed filter. Leave both date and default values blank to start with no value in the exposed filter.").

JasonNorberg’s picture

Did you ever get this resolved? I cannot get the relative date value of 'now' to work for an upcoming events block. When I switched the input to a text field the system was only looking for an absolute value (2009-01-04) not a relative value and it still ignores any relative value that I enter into the "Date default" field. Anyone help? Thanks.

Okay, so I needed to do some more reading...The Troubleshooting sections on Date and Calendar make it clear how to solve this issue.

whatleyd’s picture

Good Day,

I am having this exact same problem that all of the users are having with upcoming events. Can you point to the link for the The Troubleshooting sections on Date and Calendar make it clear how to solve this issue. I am unable to find that section in the documentation.

If anyone has found the answer to this, please let us know.

Thanks.

WorldFallz’s picture

When I had this problem it turned out to be the problem described at http://drupal.org/node/386406 and was fixed by upgrading to the latest dev version.