10 users online. Create an account or sign in to join them.Users
data source sorting by date AND time
This is an open discussion with 8 replies, filed under Troubleshooting.
Search
Since you’ll be filtering your entries in day increments, you can look at sorting time on the XSLT end: xsl:sort.
I just thought it would be easier to use the ds.
Its for invoicing I need to keep track of the amount of entries and not double invoice for things, if I do to the day its no good it has to be to the second.
I also like having the pagination info, exact number of entries etc.
I have a $ds-from-date ‘2009-11-23 16:27:11’
Im currently filtering from {$ds-specific-carrier} to {$today}
You could try something like {$ds-specific-carrier} to {$today} {$current-time} although that will only get you down to the minute, not second.
If you’re happy enough to tweak your DS by hand, try doing the following.
Open up your DS and look at the filters array. It will be something like:
public $dsParamFILTERS = array(
'1234' => '{$ds-specific-carrier} to {$today}',
...
);
Take notice of the field ID (above it is 1234).
Change/Add a __construct() function like so:
public function __construct(&$parent, $env=NULL, $process_params=true){
$this->dsParamFILTERS['1234'] = '{$ds-specific-carrier} to ' . DateTimeObj::get('Y-m-d H:i:s');
parent::__construct($parent, $env, $process_params);
$this->_dependencies = array();
}
The important bit is the first line which injects the date into the filter before it is resolved.
Oh, if you edit your DS, make sure you remove the allowEditorToParse() function, or set it to return false. This will prevent your DS from getting overwritten via the DS editor.
Hey thanks for your help, its still not working however., would it be better to break the date and time apart and check separate?
public $dsParamFILTERS = array(
//'123' => '{$carrier-id}',
//'130' => '',
);
public $dsParamINCLUDEDELEMENTS = array(
'system:pagination',
'name',
'lead-date'
);
public function __construct(&$parent, $env=NULL, $process_params=true){
$this->dsParamFILTERS['123'] = '{$carrier-id}';
$this->dsParamFILTERS['130'] = '{$ds-specific-carrier} to ' . DateTimeObj::get('Y-n-d H:i:s');
parent::__construct($parent, $env, $process_params);
$this->_dependencies = array();
}
something like this…
$this->dsParamFILTERS['130'] = '{$ds-specific-carrier} to {$today} and ' . substr('{$ds-specific-carrier}', -8) . ' to ' . substr(DateTimeObj::get('Y-n-d H:i:s'), -8);
I’ve come back to this after all this time and am still having problems.
If this worked “later than {$ds-specific-carrier}” and included the time it would be perfect.
Right now that expression shows all the entries from the same day before and after the time in the $ds
{$ds-specific-carrier} is a date structured like “2010-04-19 17:58:00”
I ended up using nils’s date and time extension as it adds the ISO time to the data source where I can check to the second.
Create an account or sign in to comment.
I know I can sort a data source from date to {$today} but how do I include time in this ?