Convert Cell value to javascript/JSON date

3 posts, 0 answers
  1. Armando Canez
    Armando Canez avatar
    5 posts
    Member since:
    Aug 2009

    Posted 26 Apr 2018 Link to this post


    I'm having a hard time using the jQuery spreadsheet  to give me a date value in javascript.

    after a button click I need to get the value of a cell as a date object. However the range.value() returns a number (not epoch or milliseconds.)


    //set the value
    currentSpreadsheet.activeSheet().range("A1").value(new Date('01/01/2018')) // no problem here
    var cellValue = currentSpreadsheet.activeSheet().range("A1").value() // in this case, cellValue returns 43101. I need the date. (01/01/2018 in this case)



    How do I convert cellValue to a javascript date?? ... or how do I access the cell so it gives me the date value? I'm not familiar how to convert this number to a Date object.


    Cell definition (all of this works fine. I only want to get the value and convert it to date):

    format: kendo.culture().calendar.patterns.d,
    transform : function(val){
      if (!val) return '';
         return (new Date(val));
    validation :{
                                 dataType: "date",
                                 showButton: true,
                                 comparerType: "between",
                                 from: 'DATEVALUE("1/1/1900")',
                                 to: 'DATEVALUE("1/1/2100")',
                                 allowNulls: !esRequerido,
                                 type: "reject",
                                 titleTemplate: " bla bla",
                                 messageTemplate: "Bla bla"


    Any help will be appreciated.


  2. Armando Canez
    Armando Canez avatar
    5 posts
    Member since:
    Aug 2009

    Posted 26 Apr 2018 in reply to Armando Canez Link to this post

    Solved It.

    For all the ones looking for the answer, The returned value is the number of days since 01/01/1900. (Not including the current day. That's why the - 1)

    var jsonDateValue = new Date((new Date('01/01/1900')).setDate(cellValue - 1)).toJSON();





  3. Dimitar
    Dimitar avatar
    809 posts

    Posted 27 Apr 2018 Link to this post

    Hello Armando,

    Thank you for sharing your solution.

    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top