0

I have variable where I have stored week range which is Essential = 'Dec 31, 2022 - Jan 6, 2023' now I want to get week number for the Essential variable I know the code for getting week no is datetime.date(2023, 1, 4).strftime("%V") however is there any alternative for getting week number based on Essential variable ..i have tried every other alternative provided on internet any help would be highly appreciated

Essential = 'Dec 31, 2022 - Jan 6, 2023'

Week number = 1

  • Does this answer your question? [How to find out week no of the month in python?](https://stackoverflow.com/questions/35391731/how-to-find-out-week-no-of-the-month-in-python) – The6thSense Jan 12 '23 at 12:18

1 Answers1

0

If need convert second date by splitting by - use:

print (int(pd.to_datetime(Essential.split(' - ')[-1], format='%b %d, %Y').strftime("%V")))
1
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252