Author Topic: Year value comes as 1969 if any date value is null  (Read 3448 times)

applepqgrid

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 26
    • View Profile
Year value comes as 1969 if any date value is null
« on: August 15, 2018, 11:50:05 pm »
Hi

In the below demo, if the 'orderDate' values is null then the date picker is showing year from '1959' to '1979' and we don't have an option to choose recent year. Can you please suggest how we can solve this issue.

https://paramquery.com/pro/demos/filter_header_local


"data": [{
      "OrderID": 10409,
      "ContactName": "Yvonne Moncada",
      "EmployeeID": 3,
      "OrderDate": null,
      "RequiredDate": "02/06/1997",
      "ShippedDate": "01/14/1997",
      "ShipVia": "Speedy Express",
      "Freight": 29.83,
      "ShipName": "Océano Atlántico Ltda.",
      "ShipAddress": "Ing. Gustavo Moncada 8585 Piso 20-A",
      "ShipCity": "Buenos Aires",
      "ShipRegion": null,
      "ShipPostalCode": "1010",
      "ShipCountry": "Argentina",
      "paid": true,
      "code": "ar"
   }, {
      "OrderID": 10531,
      "ContactName": "Yvonne Moncada",
      "EmployeeID": 7,
      "OrderDate": "AUG 14, 2018 05:59:17 AM",
      "RequiredDate": "06/05/1997",
      "ShippedDate": "05/19/1997",
      "ShipVia": "Speedy Express",
      "Freight": 8.12,
      "ShipName": "Océano Atlántico Ltda.",
      "ShipAddress": "Ing. Gustavo Moncada 8585 Piso 20-A",
      "ShipCity": "Buenos Aires",
      "ShipRegion": null,
      "ShipPostalCode": "1010",
      "ShipCountry": "Argentina",
      "paid": true,
      "code": "ar"
   }   ]
},


paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Year value comes as 1969 if any date value is null
« Reply #1 on: August 16, 2018, 05:46:16 pm »
Only dates with format "mm/dd/yy" and "yy-mm-dd" are supported in json data so please replace "AUG 14, 2018 05:59:17 AM" with "08/14/2018" in json data

and you can add format: "M dd yy" to the column to display dates in required format to end user.

applepqgrid

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Year value comes as 1969 if any date value is null
« Reply #2 on: August 16, 2018, 07:52:49 pm »
Thanks for your reply.

But we have to support date time format in all our screens (For example: Updated Time which should contain time too). Please let us know any plan for supporting date and time for date search.
« Last Edit: August 16, 2018, 07:57:18 pm by applepqgrid »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Year value comes as 1969 if any date value is null
« Reply #3 on: August 17, 2018, 08:20:24 pm »
That seems doable.

Please keep the date time in json in ISO 8601 format yy-mm-ddThh:mm:ss e.g., "2018-08-14T05:59:17"

and use any third party library for formatting date time in column.format callback function ( new in v5.3.0 ).

Code: [Select]
column.format = function(val){
  return $.xxxx.format(val, "M dd yy HH:mm:ss AM/PM");
}

applepqgrid

  • Pro Ultimate
  • Newbie
  • *
  • Posts: 26
    • View Profile
Re: Year value comes as 1969 if any date value is null
« Reply #4 on: August 18, 2018, 05:14:46 am »
Hi,


I tried your suggestions in the demo with URL https://paramquery.com/pro/demos/filter_custom# by updating as follows for 'Order Date' column. But after doing this, date filter selection itself is not working.


 { title: "Order Date", minWidth: "240", dataIndx: "OrderDate", dataType: "date",
              filter: {
                    crules: [{condition: "between" }],
                    //pass options to jQueryUI datepicker.
                    dpOptions: {
                        showWeek: true   
                    }
               
                },
          
                 format: function(val){
               
                if(val ==''){
                return val;
                }
               
               var d = new Date(val);
              
            var month=new Array(12);
            month[0]="Jan";
            month[1]="Feb";
            month[2]="Mar";
            month[3]="Apr";
            month[4]="May";
            month[5]="Jun";
            month[6]="Jul";
            month[7]="Aug";
            month[8]="Sep";
            month[9]="Oct";
            month[10]="Nov";
            month[11]="Dec";
               
            timeZoneFormatted=d.toString().match(/\(([A-Za-z\s].*)\)/)[1]
            return month[d.getMonth()] + " " + d.getDate() + ", " + d.getFullYear() +" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds()+" "+timeZoneFormatted;
            }
         
          }

Note: Date time in JSON kept correctly in format "2018-08-14T05:59:17"


Please let me know whether any demo available to check this.


Also, please let us know when V 5.3 will be available for download.

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Year value comes as 1969 if any date value is null
« Reply #5 on: August 20, 2018, 07:11:07 am »
I'm creating an example matching your requirement. v5.3.0 would be available for download today / tomorrow.
« Last Edit: August 20, 2018, 07:40:30 am by paramquery »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Year value comes as 1969 if any date value is null
« Reply #6 on: August 21, 2018, 12:01:21 am »
Please check this example https://paramquery.com/pro/demos/filter_date

for datetime formatting along with filtering for OrderDate column.