Home » Javascript » Unable to perform date filter after exporting JSON date to excel using javascript function

Unable to perform date filter after exporting JSON date to excel using javascript function

Posted by: admin August 19, 2018 Leave a comment

Questions:

I’m using below function to export JSON with dates(DD/MM/YYYY) into excel using alasql

function exportToExcel() {
    var loginInfo=[
      {
        "Login Date": "5/3/2018"
      },
      {
        "Login Date": "15/4/2018"
      },
      {
        "Login Date": "12/8/2018"
      },
      {
        "Login Date": "10/7/2018"
      }
    ];
    alasql("SELECT * INTO XLSX('test.xlsx',{headers:true}) FROM ? ",[loginInfo]);
 }
exportToExcel();

Upon exporting data to excel, since the date column is a string I’m not able to directly apply date filter in excel. Is there any way which I can make the dates appear as dates while parsing using JavaScript keeping the same format in excel further exporting so that I can filter dates ?Thanks

enter image description here enter image description here

enter image description here

Answers: