begin process at 2012 05 27 07:17:53
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Date/Heure

 > PETITES FONCTIONS POUR UTILISER LES DATES

PETITES FONCTIONS POUR UTILISER LES DATES


 Information sur la source

Note :
10 / 10 - par 1 personne
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Date/Heure Niveau :Débutant Date de création :05/05/2002 Date de mise à jour :05/05/2002 09:36:43 Vu :9 041

Auteur : pi0up51

Ecrire un message privé
Site perso
Commentaire sur cette source (0)
Ajouter un commentaire et/ou une note

 Description

Voilà qqs fonction qui failite l'utilisation des dates

Source

  • <%
  • ' Converti une date en chaine
  • Function DateToString(dDate)
  • DateToString = Year(dDate) & Right("0" & Month(dDate), 2) & Right("0" & Day(dDate), 2)
  • End Function
  • ' Converti datetime en chaine
  • Function DateTimeToString(dDateTime)
  • DateTimeToString = Year(dDateTime) & Right("0" & Month(dDateTime), 2) & Right("0" & Day(dDateTime), 2) & " " & Right("0" & Hour(dDateTime), 2) & ":" & Right("0" & Minute(dDateTime), 2) & ":" & Right("0" & Second(dDateTime), 2)
  • End Function
  • ' converti time en chaine
  • Function TimeToString(dTime)
  • TimeToString = Right("0" & Hour(dTime), 2) & ":" & Right("0" & Minute(dTime), 2) & ":" & Right("0" & Second(dTime), 2)
  • End Function
  • ' converti une chaine en date ou datetime
  • Function StringToDate(sDate)
  • Dim dDate
  • dDate = DateSerial(Left(sDate, 4), Mid(sDate, 5, 2), Mid(sDate, 7, 2))
  • If Len(sDate) > 8 Then dDate = dDate + TimeSerial(Mid(sDate, 10, 2), Mid(sDate, 13, 2), Mid(sDate, 16, 2))
  • StringToDate = dDate
  • End Function
  • ' Date au format : Jour mois année
  • Function GetDateLitteralDDMMYYYY(dDate)
  • Dim sDate
  • sDate = Day(dDate) & " " & MonthName(Month(dDate)) & " " & Year(dDate)
  • GetDateLitteralDDMMYYYY = sDate
  • End Function
  • ' Date au format : Jour mois année à Heure minutes secondes
  • Function GetDateLitteralDDMMYYYYHHMMSS(dDate)
  • Dim sDate
  • sDate = GetDateLitteralDDMMYYYY(dDate)
  • If (Hour(dDate) <> 0 or Minute(dDate) <> 0) Then sDate = sDate & " " & LANG_AT & " " & Right("0" & CStr(Hour(dDate)), 2) & "h" & Right("0" & CStr(Minute(dDate)), 2)
  • GetDateLitteralDDMMYYYYHHMMSS = sDate
  • End Function
  • ' Date au format : Jour/Mois/Année
  • Function GetDateDDMMYY(dDate)
  • GetDateDDMMYY = Right("0" & Day(dDate), 2) & "/" & Right("0" & Month(dDate), 2) & "/" & Right(Year(dDate), 2)
  • End Function
  • ' Idem sauf que anné avec 4 chiffres
  • Function GetDateDDMMYYYY(dDate)
  • GetDateDDMMYYYY = Right("0" & Day(dDate), 2) & "/" & Right("0" & Month(dDate), 2) & "/" & Year(dDate)
  • End Function
  • ' Date au format Jour/Mois/Année Heure:Minutes:Secondes
  • Function GetDateDDMMYYHHMMSS(dDateTime)
  • GetDateDDMMYYHHMMSS = GetDateDDMMYY(dDateTime) & " " & Right("0" & Hour(dDateTime), 2) & ":" & Right("0" & Minute(dDateTime), 2) & ":" & Right("0" & Second(dDateTime), 2)
  • End Function
  • %>
<%
	' Converti une date en chaine
	Function DateToString(dDate)
		DateToString = Year(dDate) & Right("0" & Month(dDate), 2) & Right("0" & Day(dDate), 2)
	End Function

	' Converti datetime en chaine
	Function DateTimeToString(dDateTime)
		DateTimeToString = Year(dDateTime) & Right("0" & Month(dDateTime), 2) & Right("0" & Day(dDateTime), 2) & " " & Right("0" & Hour(dDateTime), 2) & ":" & Right("0" & Minute(dDateTime), 2) & ":" & Right("0" & Second(dDateTime), 2)
	End Function

	' converti time  en chaine
	Function TimeToString(dTime)
		TimeToString = Right("0" & Hour(dTime), 2) & ":" & Right("0" & Minute(dTime), 2) & ":" & Right("0" & Second(dTime), 2)
	End Function

	' converti une chaine en date ou datetime
	Function StringToDate(sDate)
		Dim dDate
		dDate = DateSerial(Left(sDate, 4), Mid(sDate, 5, 2), Mid(sDate, 7, 2))
		If Len(sDate) > 8 Then dDate = dDate + TimeSerial(Mid(sDate, 10, 2), Mid(sDate, 13, 2), Mid(sDate, 16, 2))
		StringToDate = dDate
	End Function

	' Date au format : Jour mois année
	Function GetDateLitteralDDMMYYYY(dDate)
		Dim sDate
		sDate = Day(dDate) & " " & MonthName(Month(dDate)) & " " & Year(dDate)

		GetDateLitteralDDMMYYYY = sDate
	End Function

	' Date au format : Jour mois année à Heure minutes secondes
	Function GetDateLitteralDDMMYYYYHHMMSS(dDate)
		Dim sDate
		sDate = GetDateLitteralDDMMYYYY(dDate)
		
		If (Hour(dDate) <> 0 or Minute(dDate) <> 0) Then sDate = sDate & " " & LANG_AT & " " & Right("0" & CStr(Hour(dDate)), 2) & "h" & Right("0" & CStr(Minute(dDate)), 2)
		GetDateLitteralDDMMYYYYHHMMSS = sDate
	End Function

	' Date au format : Jour/Mois/Année
	Function GetDateDDMMYY(dDate)
		GetDateDDMMYY = Right("0" & Day(dDate), 2) & "/" & Right("0" & Month(dDate), 2) & "/" & Right(Year(dDate), 2)
	End Function

	' Idem sauf que anné avec 4 chiffres
	Function GetDateDDMMYYYY(dDate)
		GetDateDDMMYYYY = Right("0" & Day(dDate), 2) & "/" & Right("0" & Month(dDate), 2) & "/" & Year(dDate)
	End Function

	' Date au format Jour/Mois/Année Heure:Minutes:Secondes
	Function GetDateDDMMYYHHMMSS(dDateTime)
		GetDateDDMMYYHHMMSS = GetDateDDMMYY(dDateTime) & " " & Right("0" & Hour(dDateTime), 2) & ":" & Right("0" & Minute(dDateTime), 2) & ":" & Right("0" & Second(dDateTime), 2)
	End Function
%> 

 Conclusion

Vélà ça peut tjs servir ;)

@tte et bonn' prog'
pi0up51


 Sources du même auteur

AUTOMATISATION DES CONNECTION ET RECORDSET
NOMBRE DE CONNECTÉ (AVEC MEMBRES ;)
DERNIÈRE VISITE SUR LE SITE (COOKIE)
FONCTION DE FORMATAGE DE TEXTE
Source avec Zip FORUM STYLE ASPFR.COM (UN SEUL FICHIER ;O) [AVANCÉE]

 Sources de la même categorie

CONVERSION D'UNE DATE/HEURE STANDARD VERS DATE/HEURE CONFORM... par processus
CALCUL DE L'AGE D'UNE PERSONNE (ASP VBSCRIPT) par bluedemon
CONVERSION DE GMT À LOCAL ET DE LOCAL À GMT par revolt
Source avec Zip CALENDRIER DYNAMIQUE AVEC JOURS FERIES par label97
SAISIR DATE FR DANS MYSQL par jeckel

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,468 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales