dateteradatateradatasql

Get Date for second and fourth Friday


Given Current_Date(), how can I get the dates for the second and fourth Friday of the previous month in Teradata?

E.g., if current_date is '2025-03-25' then the dates for the second and fourth Friday will be '2025-02-14' and '2025-02-28' respectively.

TIA


Solution

  • There are lots of datetime functions in Teradata.

    trunc(add_months(current_date,-1), 'MON' returns the first of the previous month.

    td_friday returns the next friday >= a date.

    Applying some math results in:

    td_friday(trunc(add_months(current_date,-1), 'MON') + 13) as fri2,
    td_friday(trunc(add_months(current_date,-1), 'MON') + 27) as fri4