Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

[SOLVED] Only get the date portion of a datetime field in product collections
 
Thomas Hygum
Member
 
Total Posts:  36
Joined:  2009-02-25
 

I use
->addAttributeToSelect(’news_from_date’)
->addAttributeToSelect(’news_to_date’)
succesfully to get those date values in the adminhtml product grid.
But their time is always 00:00:00.
Is it possible to strip the time from the result in the product collection?
Like one would do in a SQL query: DATE(timestamp_field)…

 
Magento Community Magento Community
Magento Community
Magento Community
 
Thomas Hygum
Member
 
Total Posts:  36
Joined:  2009-02-25
 

Nice, solved myself! It is where the columns are added. I added the “type” parameter:

$this->addColumn(’news_from_date’,
array(
‘header’ => Mage::helper(’catalog’)->__(’News from’),
‘width’ => ‘40px’,
‘index’ => ‘news_from_date’,
‘type’ => ‘date’,
));

$this->addColumn(’news_to_date’,
array(
‘header’=> Mage::helper(’catalog’)->__(’News to’),
‘width’ => ‘40px’,
‘index’ => ‘news_to_date’,
‘type’ => ‘date’,
));

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top