Author Topic: Datetime format  (Read 878 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Datetime format
« on: October 05, 2022, 07:06:26 pm »
Hi

Having issue with datepicker.
Data is in format yy-mm-ddThh:mm:ss.
Column options:
Code: [Select]
dataType: 'date', format: 'yy-mm-dd hh:mm:ss', formatRaw: 'yy-mm-dd'
When selecting datepicker '2022-10-04' I get 2022-10-04 hh:10:ss...

I would like datepicker to only use date and ignore time...

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6308
    • View Profile
Re: Datetime format
« Reply #1 on: October 06, 2022, 01:40:38 pm »
column.format is the one used for displaying format.

So please use format: 'yy-mm-dd'

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Datetime format
« Reply #2 on: January 23, 2024, 12:35:42 am »
Follow up on this:

1. Does datepicker support "yy-mm-dd hh:mm", so user can select date and time?

2. Can you filter on only date and display full date and time in grid?. Example user selects 2024-01-22 and get all rows that match date regardless of time but still display it in grid?


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6308
    • View Profile
Re: Datetime format
« Reply #3 on: January 23, 2024, 06:36:53 pm »
jQueryUI datepicker is a date picker only and so custom editor or HTML5 editor has to be used to pick both date and time.

Example: OrderDate column filter in https://paramquery.com/pro/demos/filter_date 

2. it requires custom filter callback function.

Code: [Select]
{
    title: "Order DateTime", minWidth: "230", dataIndx: "OrderDate", dataType: "date",
    exportRender: true,
    filter: {
        crules: [{ condition: "equal", value: '04/07/1997' }], //initial condition and value.
conditions: {
            equal: {
                compare: function (cellData, val) {     
                    if ( val ) {                 
var d1 = new Date(cellData), d2 = new Date(val);
return (d1.getYear()== d2.getYear() && d1.getMonth()==d2.getMonth() && d1.getDate()==d2.getDate());
                    }
                    else {
                        return true;
                    }
                }
            }
        }
    }
},