Date Format

QuestionsDate Format
Aamir asked 7 years ago

Hi Abu Ghufran,
I want to have date format as dd-mm-yyyy and for this I am using this code

$g->select_command = "SELECT *, date_format(date, '%d-%m-%Y') date_of_entry FROM credit_sales WHERE sale_date BETWEEN '".$_SESSION['formatted_from_date']."' AND '".$_SESSION['formatted_to_date']."'";

$col["title"] = "Date of Entry";
$col["name"] = "date_of_entry";
$col["width"] = "100";
$col["editable"] = false;
$cols[] = $col;

This makes the format work but sorting of this column does not work any more.

Thanks and Best Regards,

3 Answers
Abu Ghufran answered 7 years ago

Debug using firebug to get actual error.
I tested it on dev, and using alias, sorting works fine.

For searching, you need to set

$col["dbname"] = "date_format(date, '%d-%m-%Y')"; // actual field name, non-alias as it will be used in WHERE clause

Aamir answered 7 years ago

Grid sorting works fine for date, not for months and years.

Abu Ghufran answered 7 years ago

I must say, this feature is fully tested in licensed version.
They are workaround for free, and may have glitches.

Your Answer

1 + 1 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.

How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?