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,237Questions: 1Answers: 2,598

    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,095Questions: 1Answers: 10,389 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,237Questions: 1Answers: 2,598

    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.