SpreadJS Pivot Table - how to convert string column to date column

Posted by: kit.leung on 6 September 2024, 5:52 am EST

  • Posted 6 September 2024, 5:52 am EST

    Dear Sir/Madam,

    Let me brief my case.

    When i try to post message to SpreadJS, i found that data in the post message can’t store date object and it will case to String format.

    Therefore, I would like to know how can i convert string column to date column from SpreadJS.

    Could you please adv.

    Attached the screen for your reference.

    Thanks,

    Best Regards,

    Kit

    SpreadJS - String column to date column.zip

  • Posted 9 September 2024, 4:33 am EST

    Hi,

    As per my understanding, the data from your backend has the “date” column, but the date is stored in the form of string. And when you try to load the data in the SpreadJS, it is not recognized as date object.

    If this is the case, you could simply use the Date Object to convert the data to the date object. You can simply convert the data coming from the backend and change the column corresponding to the date column as “Date” object.

    new Date('2021-02-27T16:00:00.000Z')

    Date Object: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

    Let me know if it doesn’t meet your use case or if you face any issues.

    Regards,

    Ankit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels