Forums

Set where conditions with desired DATE

Elita- 25 Apr, 2019
Hello, need to create a table view that contains only records with the expired date (older than today) stored in the column named 'polTerm'.
The problem is that data is stored as string like 23.05.2019 ( dd.mm.yyyy); meaning it should be converted somehow.
So - the question is - how can I write the WHERE conditions in DB ReadData function to have this accomplished?

I have working code that hightlights the date in the table; now i want to show only those rows that contains expired date:
$polterm = $this->get('submissions_list.row.Submission.polTerm');  // stored as DD.MM.YYYY
$endDate = new DateTime($polterm);
$curdate = new DateTime(date('d.m.Y'));

if($curdate > $endDate){
echo '<div style="color: red;">'.$this->get('submissions_list.row.Submission.polTerm').'</div>';
}else{
echo $this->get('submissions_list.row.Submission.polTerm');
}
Thank you in advance-
Elita
healyhatman 25 Apr, 2019
Try
date > DATEADD(day, 10, GetDate())
Elita- 25 Apr, 2019
thanks, healyhatman,
khm. So "Where conditions" would be what? in the ReadData function?
Ifa I had date stored correctly, I would be able to have this code or smth like this, I believe
Submission.polTerm/<=: {date:Y-m-d} 

hovewer i have date stored as string in the format d.m.Y

So, how i can get this working?

Elita
Elita- 25 Apr, 2019
I think I figured it out:
(STR_TO_DATE(polTerm,'%d.%m.%Y'))/<=:{date:Y-m-d}
However something seems "messing arround" - I cannot get that column to be ordered properly - it creates the order from days - 31.03.2019, 30.01.2019, 28.03.2019.... etc.
How can I fix this?
healyhatman 25 Apr, 2019
Put the column you want ordered by in the ordered by setting
This topic is locked and no more replies can be posted.