Skip to content

Instantly share code, notes, and snippets.

@paul-d-ray
Created September 19, 2025 17:00
Show Gist options
  • Select an option

  • Save paul-d-ray/6b9e83ef8d6d2636d94477996e32aab4 to your computer and use it in GitHub Desktop.

Select an option

Save paul-d-ray/6b9e83ef8d6d2636d94477996e32aab4 to your computer and use it in GitHub Desktop.
Nushell Get Last Friday of Each Month of a Year

Last Friday of Each Month

I had a need to get the last Friday of each month of 2025.

  • This can be changed to get any other last day by changing the wday variable.
    • su, mo, tu, we, th, fr, sa

Nushell Code

let wday = 'fr'
let year = 2025
cal -m -t --week-start $wday --full-year $year |
group-by month |
items {|mon cal| 
  {Friday: ($'($year)-($mon)-($cal | last | get $wday)' |
  format date "%F" )
  }
}

Output

╭────┬────────────╮
│  # │   Friday   │
├────┼────────────┤
│  0 │ 2025-01-31 │
│  1 │ 2025-02-28 │
│  2 │ 2025-03-28 │
│  3 │ 2025-04-25 │
│  4 │ 2025-05-30 │
│  5 │ 2025-06-27 │
│  6 │ 2025-07-25 │
│  7 │ 2025-08-29 │
│  8 │ 2025-09-26 │
│  9 │ 2025-10-31 │
│ 10 │ 2025-11-28 │
│ 11 │ 2025-12-26 │
├────┼────────────┤
│  # │   Friday   │
╰────┴────────────╯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment