Bonjour

Je recherche comment éviter dans les commandes
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
  print(str(DateDbut))
   print(str(DateFin))
d'avoir ceci "2016-01-01 00:00:00"
je cherche a ne par voir la partie horaire qui ne m’intéressent pas dans certain cas


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# coding: utf-8  
import string
import sys
 
import datetime
 
 
 
from _overlapped import NULL
from calendar import format
 
 
def convertie_date(src):
    if src =='99991231':
        valid_date = NULL
    else:
        alpha_aaaa = src[0:4] 
        alpha_mm =   src[4:6] 
        alpha_jj =  src[6:8] 
        date_format = '%Y/%m/%d'
        my_date=alpha_aaaa+"/"+ alpha_mm + "/"+alpha_jj
        try :
            valid_date = datetime.datetime.strptime(my_date, date_format)
            return valid_date
        except ValueError:
            print('%s Date invalide !' % my_date)
        return None
    pass  
 
 
 
 
# Base Application
if __name__ == '__main__':
 
   date ="2016010199991231"
   DtDb= date[0:8]
   DtFn= date[8:16]
   print(DtDb)
   print(DtFn)
 
   DateDbut =convertie_date(DtDb)
   DateFin =convertie_date(DtFn) 
   print(str(DateDbut))
   print(str(DateFin))