KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

DATETIMEPICKER default date based on DATABASE DATE COLUMN #766

Closed iRiyada opened this topic on on Mar 28, 2019 - 5 comments

iRiyada commented on Mar 28, 2019

I want to assign the initial default start date and end date to a linked datetimepicker from the database dynamically using query. Pls suggest how to assign default date using query from db.

Is there any option for daatetimepicker to specify the query directly as an option of default date?

<?php
                  DateTimePicker::create(array(
                      "name"=>"max",
                      "minDate"=>"@min",
                      "locale"=>"ar-kw",
                      "format"=>"YYYY-MM-DD",
                      "themeBase"=>"bs3"
                  ));
                  ?>
KoolReport commented on Mar 29, 2019

You can use the "value" property to set the initial value for DateTimePicker.

iRiyada commented on Mar 29, 2019

I tried this, with value property. ` <?php

              DateTimePicker::create(array(
                  "name"=>"min",
                  "maxDate"=>"@max",
                  "locale"=>"ar-kw",
                  "format"=>"YYYY-MM-DD",
                  "value"=>$this->src("mysql")->query("select cast(min(v.creation_date) as date) min_date from v_task_status v"),
                "themeBase"=>"bs3"
              ));
              ?>
but it is showing error.
DateTime::__construct() expects parameter 1 to be string, object given
KoolReport commented on Mar 30, 2019

The value takes the string type which is the datetime so actually you need to do this:

$this->src("mysql")->query("your-query")->pipe($this->dataStore("mindate"))->requestDataSending();
$mindate = $this->dataStore("mindate")->get(0,"date"); //Return date column of first row

then in the DateTimePicker

"value"=>$mindate
iRiyada commented on Mar 30, 2019

It worked.Thanks..

KoolReport commented on Mar 30, 2019

Great!

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
solved

None