0

I have an excel column which is a date column with values like 1-JAN-22.

But when I read using openpyxl the value shows as 2022-01-01 00:00:00.

I'm extracting the value with value = sh[cell_name].value

How do I extract as I see in excel, 1-Jan-22? I just want to extract this string.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

1 Answers1

0

If you are on Windows, try

value = datetime.date.strftime(sh['A1'].value, "%#d-%b-%y")

If on Linux, try

value = datetime.date.strftime(sh['A1'].value, "%-d-%b-%y")

Output:

'1-Jan-22'