最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

teradata - Get Date for second and fourth Friday - Stack Overflow

programmeradmin5浏览0评论

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

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

Share Improve this question asked Mar 25 at 9:30 darkagedarkage 8693 gold badges14 silver badges23 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

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
发布评论

评论列表(0)

  1. 暂无评论