I have a week number and a year (e.g. 34 and 2015). I want to get the name of the month to which the specified week belongs.
How can I do that?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.
Sign up to join this communityI have a week number and a year (e.g. 34 and 2015). I want to get the name of the month to which the specified week belongs.
How can I do that?
Please try this:
SELECT MONTHNAME(STR_TO_DATE('201534 Monday','%X%V %W')) month_name
Instead of hardcoding the values, you can pass dynamic value also.
I solved my problem with this Perl logic:
my $time_piece_obj = Time::Piece->strptime('2016-01-01', '%Y-%m-%d');
my $ONE_WEEK = 604800;
my $wk_no=20;
$time_piece_obj += $wk_no*$ONE_WEEK;
my $month_name= $time_piece_obj->month;
print $month_name;