Filter on the month of a date in a fetch

Author Message

Anthony M.

Monday 08 January 2007 6:01:42 am

Hi,

i want to make a filter on a 'date and time' attribute (the attribute is 'mydate' in the class 'myclass') in my fetch, i would like to filter only with the month, for example '01' (to the month of january) :

{def $evenements = fetch( 'content', 'list', hash( 'parent_node_id', 125, 'attribute_filter', array(array('myclass/mydate','=','01')) ) )}

but it's not possible like this, i don't know how to filter only with the month...

Thanks
Anthony

Anthony

Eirik Alfstad Johansen

Tuesday 16 January 2007 9:10:29 am

Hi Anthony,

AFAIK, the date time datatype stores data as timestamps. In order to accomplish what you're trying to do, I think you need to convert the first and last day of the month to timestamps, and then fetch objects where the date is higher than the first timestamp and lower than the second.

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

B. Vollmer

Friday 19 January 2007 6:59:06 am

Hi,

I have a similiar problem with the usage of attribute_filter. I want to get the next 5 items of my event content class from today on. I tested the following statement without success:

{def timestamp=maketime() $events=fetch( 'content','tree',hash( 'parent_node_id', $parentnodeid,attribute_filter, array( $idcontentclass, '>=', $timestamp ),class_filter_type, include,class_filter_array, array('events'),'limit', 5))}

I don't understand how to use attribute_filter. Can somebody give me a tip?

Sébastien Morel

Friday 19 January 2007 7:36:49 am

Hi,

{def 
	$timestamp=maketime()
	$events=fetch( 'content','tree',hash( 
				parent_node_id, $parentnodeid,
				attribute_filter, array( array( $idcontentattributeclass, '>=', $timestamp )),
				class_filter_type, 'include',
				class_filter_array, array('events'),
				'limit', 5
				)
			)
}
 

{def} need a $ before variable timestamp no ?

++

--
eZ c'est plus fort que toi !
http://www.ez-france.org
http://blog.plopix.net
@Novactive (http://www.novactive.com)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.