KoolReport's Forum

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

Datetime sorting not follow the sequence #810

Open henry opened this topic on on Apr 16, 2019 - 2 comments

henry commented on Apr 16, 2019

hi i'm build a report using date time, but the date time arrangement are not follow the sequence....can anyone help? Below are the source code and report outcome.

    public function setup()
    {
        $this->src('sales')
        ->query("SELECT order_date,total_bill FROM dborder")
        ->pipe(new DateTimeFormat(array(
            "order_date"=>array(
                "from"=>"Y-m-d H:i:s",
                "to"=>"jS M, Y",
            )
        )))
        ->pipe(new Group(array(
            "by"=>"order_date",
            "sum"=>"total_bill"
        )))

        ->pipe(new Limit(array(30)))
        ->pipe($this->dataStore('Total_Sales_Daily'));
    }

KoolReport commented on Apr 16, 2019

You do this:

        $this->src('sales')
        ->query("SELECT order_date,total_bill FROM dborder")
        ->pipe(new DateTimeFormat(array(
            "order_date"=>array(
                "from"=>"Y-m-d H:i:s",
                "to"=>"Y-m-d",
            )
        )))
        ->pipe(new Group(array(
            "by"=>"order_date",
            "sum"=>"total_bill"
        )))

        ->pipe(new Limit(array(30)))
        ->pipe($this->dataStore('Total_Sales_Daily'));

And then later in LineChart you do:

LineChart::create(array(
    "columns"=>array(
        "order_date"=>array(
            "displayFormat"=>"jS M, Y"
        )
    )
))

Basically we keep the Y-m-d format for sorting and then later we change to desired format to display.

henry commented on Apr 17, 2019

thanks for help, its work

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

CloudExport