Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
173 views
in Technique[技术] by (71.8m points)

sql - I want to write a stored procedure that generates the certain attributes for a date, for one year

For example we take the date "2020-01-15"

Your procedure is supposed to populate the data till "2021-061-15" and it will derive some date attributes for all the dates that come between "2020-01-15" and "2021-01-15":

The detailed list of the attributes (the name of the attributes will be the name of the columns) you are supposed to derive is as following:

  • SKDATE- String containing the date in yyyymmdd format. (20200115)
  • Date: 2020-01-15
  • CalendarDay- 15.
  • CalendarMonth- 01
  • CalendarYear- 2020.
  • CalendarQuarter- 2 [The quarter we are in ].
  • DayNameLong- Monday.
  • DayNameShort- Mon
  • DayNumberOfWeek- 1 (Considering Sunday as 0)
  • DayNumberOfYear- Number of day of the calendar.
  • DaySuffix- String containing the day number and suffix.(1st,2nd,3rd)
  • Fiscal Week- Number of the week of the calendar.
  • Fiscal Period- Fiscal month number of the calendar
  • FiscalQuarter- Fiscal quarter number of the calendar
  • Fiscal Year- Fiscal year in yyyy format
  • Fiscal Year/Period- String containing fiscal year and fiscal period in yyyymm format. (20031)

PS- You are not allowed to use more than one INSERT INTO statement.

question from:https://stackoverflow.com/questions/65914477/i-want-to-write-a-stored-procedure-that-generates-the-certain-attributes-for-a-d

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...