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
'-------------------------------------------------------------
'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:
Auteur: Michel Preti
Révision: 1.0
Vous ne pouvez pas commenter cet enregistrement