Conversion of date formats

Rohan Limaye

I wanted to convert a list containing dates in the format:

01 MAR 2020

Into this format :

2020-03-01 (YYYY-MM-DD) 

using python. Is there a way to do this??

niko

Yes using datetime

from datetime import datetime

# Python object
datetime.strptime("01 MAR 2020", "%d %b %Y")
# datetime.datetime(2020, 3, 1, 0, 0)

# Converted Format
datetime.strptime("01 MAR 2020", "%d %b %Y").strftime('%F')
# 2020-03-01'

PS The locale used might cause problems when dealing with non-numeric months. See here for help on the topic.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Regarding converting Date formats

分類Dev

Converting Date formats in R

分類Dev

Convert a a character column to date with multiple formats

分類Dev

Issues converting strings to numeric date formats R

分類Dev

Date conversion to a different locale

分類Dev

DATE CONVERSION SCALA

分類Dev

PHP String to date conversion

分類Dev

Sql Server string to date conversion

分類Dev

Notice: Array to string conversion with date

分類Dev

Date conversion and subtraction in shell script

分類Dev

bigInt to date conversion giving errors

分類Dev

Excel Date& Time Conversion

分類Dev

Java String Date conversion issue

分類Dev

Format multiple date formats in one columns using lubridate

分類Dev

Converting date formats after executing stored procedure via Powershell?

分類Dev

How do I convert date formats using a regex in R?

分類Dev

Parse multiple date formats into a single format-further question

分類Dev

How to subtract two different date formats to get days in bash?

分類Dev

Conversion of number to date affect the performance in oracle

分類Dev

PHP date() to Excel serial format conversion

分類Dev

Date conversion to specific format using Angular pipes

分類Dev

Default Date to JSON conversion format in Angular app

分類Dev

Java - SimpleDateFormat string to Date to mills conversion

分類Dev

MySQL date conversion(“01/Jan/2015” to “01012015”)

分類Dev

Date time conversion in Javascript from format "/Date(1535515200000)/"

分類Dev

Weird Date formats part of column in YY-mm-dd and the rest of columns YY-dd-mm

分類Dev

iOS Swift Same code results in different date formats when run on iPad and iPhone

分類Dev

How to convert list to dataframe without type conversion on date

分類Dev

SQL Server Date time conversion giving incorrect result?

Related 関連記事

  1. 1

    Regarding converting Date formats

  2. 2

    Converting Date formats in R

  3. 3

    Convert a a character column to date with multiple formats

  4. 4

    Issues converting strings to numeric date formats R

  5. 5

    Date conversion to a different locale

  6. 6

    DATE CONVERSION SCALA

  7. 7

    PHP String to date conversion

  8. 8

    Sql Server string to date conversion

  9. 9

    Notice: Array to string conversion with date

  10. 10

    Date conversion and subtraction in shell script

  11. 11

    bigInt to date conversion giving errors

  12. 12

    Excel Date& Time Conversion

  13. 13

    Java String Date conversion issue

  14. 14

    Format multiple date formats in one columns using lubridate

  15. 15

    Converting date formats after executing stored procedure via Powershell?

  16. 16

    How do I convert date formats using a regex in R?

  17. 17

    Parse multiple date formats into a single format-further question

  18. 18

    How to subtract two different date formats to get days in bash?

  19. 19

    Conversion of number to date affect the performance in oracle

  20. 20

    PHP date() to Excel serial format conversion

  21. 21

    Date conversion to specific format using Angular pipes

  22. 22

    Default Date to JSON conversion format in Angular app

  23. 23

    Java - SimpleDateFormat string to Date to mills conversion

  24. 24

    MySQL date conversion(“01/Jan/2015” to “01012015”)

  25. 25

    Date time conversion in Javascript from format "/Date(1535515200000)/"

  26. 26

    Weird Date formats part of column in YY-mm-dd and the rest of columns YY-dd-mm

  27. 27

    iOS Swift Same code results in different date formats when run on iPad and iPhone

  28. 28

    How to convert list to dataframe without type conversion on date

  29. 29

    SQL Server Date time conversion giving incorrect result?

ホットタグ

アーカイブ