convert days by weeks

convert days by weeks

bechirmradbechirmrad Posts: 20Questions: 6Answers: 0

i want to convert the days in the datatable in another column but with weeks of the year !!
like week 1 week 2 ...
and thanks

Replies

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @bechirmrad ,

    You can use a function in columns.render to do the maths - see the fourth example on that page. For the maths, best bet is to Google it, I just tried and there's a quite a few hits.

    Cheers,

    Colin

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    MomentJS is my go to library for date and time calculations.

    Allan

  • bechirmradbechirmrad Posts: 20Questions: 6Answers: 0

    ok i will try

  • bechirmradbechirmrad Posts: 20Questions: 6Answers: 0

    This example ??
    $('#example').dataTable( {
    "columnDefs": [ {
    "targets": 0,
    "data": "download_link",
    "render": function ( data, type, row, meta ) {
    return '<a href="'+data+'">Download</a>';
    }
    } ]
    } );

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Yep, so instead of returning (displaying) the value of "data" as it would normally do, it now forms a "href" instead. Here, you would grab the value from "row" for the other date, do your conversion, and return the week number.

This discussion has been closed.