Converting date between DD/MM/YYYY and YYYY-MM-DD?

前端 未结 6 1971
隐瞒了意图╮
隐瞒了意图╮ 2020-12-23 16:24

Using a Python script, I need to read a CVS file where dates are formated as DD/MM/YYYY, and convert them to YYYY-MM-DD before saving this into a SQLite database.

Th

6条回答
  •  Happy的楠姐
    2020-12-23 17:21

    #case_date= 03/31/2020   
    
    #Above is the value stored in case_date in format(mm/dd/yyyy )
    
    demo=case_date.split("/")
    new_case_date = demo[1]+"-"+demo[0]+"-"+demo[2]
    #new format of date is (dd/mm/yyyy) test by printing it 
    print(new_case_date)
    

提交回复
热议问题