Vbscript

ID #1060

Fonction permettant d'obtenir une date formattée

Fonction permettant d'obtenir une date formattée

'-------------------------------------------------------------
'Fonction   : GetDateString
'Description: Fonction permettant d'obtenir une date en string dans le format suivant: 20070402_080602
'Input      : Date
'Output     : String
'Création   : 2003.10.16 Michel Preti
'Note       : Les fonctions FORMAT et IIF ne fonctionnent
'             pas en VBScript.
'-------------------------------------------------------------
Public Function GetDateString(dteTemp)
    Dim strOutput
    
'Partie date -----------------------------
    strOutput = Year(dteTemp)
    
    'Partie Date Mois
    If Month(dteTemp) < 10 Then
        strOutput = strOutput & "0" & Month(dteTemp)
    Else
        strOutput = strOutput & Month(dteTemp)
    End If
    
    'Partie Date Jour
    If Day(dteTemp) < 10 Then
        strOutput = strOutput & "0" & Day(dteTemp)
    Else
        strOutput = strOutput & Day(dteTemp)
    End If
       
    'Séparateur
    strOutput = strOutput & "_"

'Partie heure ----------------------------
    'Partie Heure Heure
    If Hour(dteTemp) < 10 Then
        strOutput = strOutput & "0" & Hour(dteTemp)
    Else
        strOutput = strOutput & Hour(dteTemp)
    End If
 
    'Partie Heure Minute
    If Minute(dteTemp) < 10 Then
        strOutput = strOutput & "0" & Minute(dteTemp)
    Else
        strOutput = strOutput & Minute(dteTemp)
    End If
 
    'Partie Heure Seconde
    If Second(dteTemp) < 10 Then
        strOutput = strOutput & "0" & Second(dteTemp)
    Else
        strOutput = strOutput & Second(dteTemp)
    End If
 
 
    GetDateString = strOutput

End Function

Tags: -

Related entries:

Dernière mise à jour: 2007-12-29 20:15
Auteur: Michel Preti
Révision: 1.0

Digg it! Imprimer cet article Envoyer à un ami version PDF
Propose a translation for Propose a translation for
Merci de noter cette entrée:

Moyenne des notes: 0 sur 5 (0 Votes)

complètement inutile 1 2 3 4 5 indispensable

Vous ne pouvez pas commenter cet enregistrement