MySQL Forums
Forum List  »  General

Dynamic assignment of month based on current date
Posted by: Arun Chandramouli
Date: April 11, 2022 12:24PM

Hi All,

Hope you are doing well!...I am trying to convert the plan table as below




Input
Segment Model FC1 FC2 FC3 FC4 FC5 FC6 FC7 FC8 FC9 FC10 FC11 FC12
HRX P3412 9 14 11 22 17 23 18 15 23 12 12 19
SRX O321 11 8 8 9 9 16 19 7 22 12 11 15
SRX LD12 14 10 20 22 18 19 10 17 21 16 10 21
HRX M421 17 18 16 12 14 17 10 16 8 8 7 23
MRX N342 3 23 16 13 20 9 16 14 16 17 10 11
HRX J231 4 10 20 20 21 23 17 22 14 15 8 22

into the table below based on the current date and the reference table

Segment Model Apr-22 May-22 Jun-22 Jul-22 Aug-22 Sep-22 Oct-22 Nov-22 Dec-22 Jan-23 Feb-23 Mar-23
HRX P3412 9 14 11 22 17 23 18 15 23 12 12 19
SRX O321 11 8 8 9 9 16 19 7 22 12 11 15
SRX LD12 14 10 20 22 18 19 10 17 21 16 10 21
HRX M421 17 18 16 12 14 17 10 16 8 8 7 23
MRX N342 3 23 16 13 20 9 16 14 16 17 10 11
HRX J231 4 10 20 20 21 23 17 22 14 15 8 22


Reference table:



Fiscal Month From to
Jan-22 Dec 26 2021 Jan 22 2022
Feb-22 Jan 23 2022 19-Feb-22
Mar-22 20-Feb-22 26-Mar-22
Apr-22 27-Mar-22 23-Apr-22
May-22 24-Apr-22 21-May-22
Jun-22 22-May-22 25-Jun-22
Jul-22 26-Jun-22 23-Jul-22
Aug-22 24-Jul-22 20-Aug-22
Sep-22 21-Aug-22 24-Sep-22
Oct-22 25-Sep-22 22-Oct-22
Nov-22 23-Oct-22 19-Nov-22
Dec-22 20-Nov-22 31-Dec-22

So I need to basically map the column names (FC1,FC2,FC3...input table) to fiscal month based on the current date and looking up the reference table for the fiscal month... I have attached the excel data for the above too...Can you please help me with the mysqlquery for the same..

The column names should change every fiscal month according to the reference table dynamically ..For example FC1 should be renamed to May 2022 and FC2 should be renamed to June 2022 from 24th April 2022...Similarly from 22nd may 2022 FC1 should be renamed to June 2022, FC2 should be renamed to July 2022...

Options: ReplyQuote


Subject
Written By
Posted
Dynamic assignment of month based on current date
April 11, 2022 12:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.