coldfusioncfml

week to first day of week


I have a week formatted like this: 2023-W12 (for Week 12 in 2023).

I need to get the first day of that week (in this case Monday, 2023-03-20 (yyyy-mm-dd)).

But I can only use plain cfml to achieve this, as of the systems limitation.

I tried dateFormat('2023-W12', 'yyyy-mm-dd') which leads to this error:

The value of parameter 1, which is currently 2023-W12, must be a class java.util.Date value.

Any hints on how I could do this?


Solution

  • You can try using the parseDateTime function.

    var date = parseDateTime( '2023-W12', "YYYY-'W'w");
    // date is {ts '2023-03-19 00:00:00'}