ListPage Fields

5 posts by 3 authors in: Forums > CMS Builder
Last Post: August 10, 2023   (RSS)

By mabsi - August 6, 2023 - edited: August 7, 2023

Hello

How to display number of days from creation date till today in the ListPage Fields 

Like below example:

Record No.      Creation Date     No. of Days
-------------------------------------------------------------------

     1                   2023-08-01              5

No. of Days=   NOW() - Creation date 

By robin - August 7, 2023

Hi Mabsi,

Looks like you want to do this in sql?  Check out the mysql DATEDIFF function.  Something like
https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_datediff

DATEDIFF(NOW(), createdDate);

Hope that helps!  Thanks,
Robin

Robin
Programmer
interactivetools.com

By mabsi - August 7, 2023 - edited: August 8, 2023

Thank you Robin for your reply

My question how to display the result of the query on CMSB  ListPage Fields and what should the field type

I tried using separator field as below code

<?php
$date1 = new DateTime(@$RECORD['createdDate']);
$date2 = new DateTime(date("Y-m-d H:i:s"));
$interval = $date1->diff($date2);
$days=$interval->days;
?>

<input type="text" style="width: 100%" name="lock_period" value="<?php echo $days;?>" readonly class="text-input form-control" data-dirrty-initial-value="">

its return the value in edit page as expected but didn't displayed on in the list page

Please find attached screen shot for more clarification 

Attachments:

Capture.JPG 51K

By mabsi - August 10, 2023

Thank you Dave for your reply.

I will try and post here the solution