I have a table where I save a period as yyyy-mm, this period is a varchar field, when I want to get the max of that field with $periodMax = $this->Contributions->find('all')->where(['enterprise_id' => $this->enterprise_id])->select(['period' => $queryMax->func()->max('period')])->first();
it only returns the year without the month, how can I do to get the whole value of that field?
This is what it shows debug($periodMax)
:
APP/Controller\ContributionsController.php (line 174)
object(App\Model\Entity\Contribution) id:0 {
'period' => (float) 2024
'[new]' => false
'[accessible]' => [
'enterprise_id' => true,
'sword_declaration_number' => true,
'period' => true,
'created' => true,
'modified' => true,
'enterprise' => true,
'affiliates_contributions' => true,
]
'[dirty]' => [
]
'[original]' => [
]
'[virtual]' => [
]
'[hasErrors]' => false
'[errors]' => [
]
'[invalid]' => [
]
'[repository]' => 'Contributions'
}