Bonsoir et joyeux noël à tous,
Suite à import de fichier texte, je cherche à convertir en format date
classique une chaîne texte du type jj-mmm-aaaa (ex : 10-dec-2003).
Je précise qu'il n'y a pas d'accent dans le texte d'origine(dec au lieu de
déc).
où la fonction Month_str2Num se définit comme suit :
'==================================ÞBUT DU CODE Function Month_Str2Num(sMonth As String) As Long Select Case sMonth Case "jan", "janv", "janvier", "january" Month_Str2Num = 1 Case "feb", "févr", "fev", "férier", "february" Month_Str2Num = 2 Case "mar", "mars", "march" Month_Str2Num = 3 Case "apr", "avril", "avr", "april" Month_Str2Num = 4 Case "may", "mai" Month_Str2Num = 3 Case "jun", "juin", "june" Month_Str2Num = 6 Case "jul", "juil", "juillet", "july" Month_Str2Num = 7 Case "aug", "août", "august" Month_Str2Num = 8 Case "sep", "sept", "septembre", "september" Month_Str2Num = 9 Case "oct", "octobre", "october" Month_Str2Num = 10 Case "nov", "novembre", "november" Month_Str2Num = 11 Case "dec", "déc", "décembre", "december" Month_Str2Num = 12 End Select End Function '===================================FIN DU CODE
où la fonction Month_str2Num se définit comme suit :
'==================================ÞBUT DU CODE
Function Month_Str2Num(sMonth As String) As Long
Select Case sMonth
Case "jan", "janv", "janvier", "january"
Month_Str2Num = 1
Case "feb", "févr", "fev", "férier", "february"
Month_Str2Num = 2
Case "mar", "mars", "march"
Month_Str2Num = 3
Case "apr", "avril", "avr", "april"
Month_Str2Num = 4
Case "may", "mai"
Month_Str2Num = 3
Case "jun", "juin", "june"
Month_Str2Num = 6
Case "jul", "juil", "juillet", "july"
Month_Str2Num = 7
Case "aug", "août", "august"
Month_Str2Num = 8
Case "sep", "sept", "septembre", "september"
Month_Str2Num = 9
Case "oct", "octobre", "october"
Month_Str2Num = 10
Case "nov", "novembre", "november"
Month_Str2Num = 11
Case "dec", "déc", "décembre", "december"
Month_Str2Num = 12
End Select
End Function
'===================================FIN DU CODE
où la fonction Month_str2Num se définit comme suit :
'==================================ÞBUT DU CODE Function Month_Str2Num(sMonth As String) As Long Select Case sMonth Case "jan", "janv", "janvier", "january" Month_Str2Num = 1 Case "feb", "févr", "fev", "férier", "february" Month_Str2Num = 2 Case "mar", "mars", "march" Month_Str2Num = 3 Case "apr", "avril", "avr", "april" Month_Str2Num = 4 Case "may", "mai" Month_Str2Num = 3 Case "jun", "juin", "june" Month_Str2Num = 6 Case "jul", "juil", "juillet", "july" Month_Str2Num = 7 Case "aug", "août", "august" Month_Str2Num = 8 Case "sep", "sept", "septembre", "september" Month_Str2Num = 9 Case "oct", "octobre", "october" Month_Str2Num = 10 Case "nov", "novembre", "november" Month_Str2Num = 11 Case "dec", "déc", "décembre", "december" Month_Str2Num = 12 End Select End Function '===================================FIN DU CODE
GL
Bonsoir. Merci beaucoup Maxence, ça marche! garri
"Maxence HUBICHE" a écrit dans le message de news:
où la fonction Month_str2Num se définit comme suit :
'==================================ÞBUT DU CODE Function Month_Str2Num(sMonth As String) As Long Select Case sMonth Case "jan", "janv", "janvier", "january" Month_Str2Num = 1 Case "feb", "févr", "fev", "férier", "february" Month_Str2Num = 2 Case "mar", "mars", "march" Month_Str2Num = 3 Case "apr", "avril", "avr", "april" Month_Str2Num = 4 Case "may", "mai" Month_Str2Num = 3 Case "jun", "juin", "june" Month_Str2Num = 6 Case "jul", "juil", "juillet", "july" Month_Str2Num = 7 Case "aug", "août", "august" Month_Str2Num = 8 Case "sep", "sept", "septembre", "september" Month_Str2Num = 9 Case "oct", "octobre", "october" Month_Str2Num = 10 Case "nov", "novembre", "november" Month_Str2Num = 11 Case "dec", "déc", "décembre", "december" Month_Str2Num = 12 End Select End Function '===================================FIN DU CODE
Bonsoir.
Merci beaucoup Maxence, ça marche!
garri
"Maxence HUBICHE" <mhms@club-internet.fr> a écrit dans le message de news:
227E45A4-A060-441C-B41D-1343364C6BCB@microsoft.com...
où la fonction Month_str2Num se définit comme suit :
'==================================ÞBUT DU CODE
Function Month_Str2Num(sMonth As String) As Long
Select Case sMonth
Case "jan", "janv", "janvier", "january"
Month_Str2Num = 1
Case "feb", "févr", "fev", "férier", "february"
Month_Str2Num = 2
Case "mar", "mars", "march"
Month_Str2Num = 3
Case "apr", "avril", "avr", "april"
Month_Str2Num = 4
Case "may", "mai"
Month_Str2Num = 3
Case "jun", "juin", "june"
Month_Str2Num = 6
Case "jul", "juil", "juillet", "july"
Month_Str2Num = 7
Case "aug", "août", "august"
Month_Str2Num = 8
Case "sep", "sept", "septembre", "september"
Month_Str2Num = 9
Case "oct", "octobre", "october"
Month_Str2Num = 10
Case "nov", "novembre", "november"
Month_Str2Num = 11
Case "dec", "déc", "décembre", "december"
Month_Str2Num = 12
End Select
End Function
'===================================FIN DU CODE
où la fonction Month_str2Num se définit comme suit :
'==================================ÞBUT DU CODE Function Month_Str2Num(sMonth As String) As Long Select Case sMonth Case "jan", "janv", "janvier", "january" Month_Str2Num = 1 Case "feb", "févr", "fev", "férier", "february" Month_Str2Num = 2 Case "mar", "mars", "march" Month_Str2Num = 3 Case "apr", "avril", "avr", "april" Month_Str2Num = 4 Case "may", "mai" Month_Str2Num = 3 Case "jun", "juin", "june" Month_Str2Num = 6 Case "jul", "juil", "juillet", "july" Month_Str2Num = 7 Case "aug", "août", "august" Month_Str2Num = 8 Case "sep", "sept", "septembre", "september" Month_Str2Num = 9 Case "oct", "octobre", "october" Month_Str2Num = 10 Case "nov", "novembre", "november" Month_Str2Num = 11 Case "dec", "déc", "décembre", "december" Month_Str2Num = 12 End Select End Function '===================================FIN DU CODE