Accueil > > > CONVERTION DE DATE J/M/AAAA EN AAAAMMJJ ET HEURE H:M EN HHMM
CONVERTION DE DATE J/M/AAAA EN AAAAMMJJ ET HEURE H:M EN HHMM
Information sur la source
Description
Pratique pour utiliser de l'information date et heure entre Page Web et DataBase. Sans avoir de problème de convertion de paramètre Régionaux qui sont toujours problèmatique.
Source
- Public Function DateDBToPage(ByVal pDate As String) As String
- ' Composition d'une date de base de donnée style AAAAMMJJ vers JJ/MM/AAAA
- If pDate.Length = 8 Then
- Return Mid(pDate, 7, 2) + "/" + Mid(pDate, 5, 2) + "/" + Mid(pDate, 1, 4)
- Else
- Return ""
- End If
- End Function
-
- Public Function HeureDBToPage(ByVal pHeure As String) As String
- ' Composition d'une Heure de base de donnée style HHMM vers HH:MM
- If pHeure.Length = 4 Then
- Return Mid(pHeure, 1, 2) + ":" + Mid(pHeure, 3, 2)
- Else
- Return ""
- End If
- End Function
-
-
- ' -------------------------------------------------------------------------------
- Public Function DatePageToDb(ByVal pDate As String) As String
- ' -------------------------------------------------------------------------------
- ' Composition d'une date JJ/MM/AAAA pour une base de donnée style AAAAMMJJ
- If pDate.Length >= 8 Then
- Dim x1 As Integer = pDate.IndexOf("/") + 1 ' Récup position du premier "/"
- Dim x2 As Integer = pDate.IndexOf("/", x1 + 1) + 1 ' Récup position du deuxième "/"
- Dim aaaa, mm, jj As String
-
- aaaa = Mid(pDate, x2 + 1, pDate.Length - x2)
- If aaaa.Length = 2 Then aaaa = "20" + aaaa ' On vérifie si une date sur 2 position on complète avec 20xx
- aaaa = aaaa.PadLeft(4, "0")
- mm = Mid(pDate, x1 + 1, x2 - x1 - 1).PadLeft(2, "0")
- jj = Mid(pDate, 1, x1 - 1).PadLeft(2, "0")
-
- Return aaaa + mm + jj
- Else
- Return ""
- End If
-
- End Function
-
- ' -------------------------------------------------------------------------------
- Public Function HeurePageToDb(ByVal pHeure As String) As String
- ' -------------------------------------------------------------------------------
- ' Composition d'une heure HH:MM pour une base de donnée style HHMM
- If pHeure.Length >= 3 Then
- Dim x1 As Integer = pHeure.IndexOf(":") + 1 ' Récup position du ":"
- Dim x2 As Integer = pHeure.Length
- Dim hh, mm As String
-
- If x1 < 0 Then
- ' Il n'y à pas de ':' dans l'heure on la justifie comme ca sur 4 positions
- hh = Format(Int(pHeure), "0000")
- Return hh
- Else
- mm = Mid(pHeure, x1 + 1, x2 - x1).PadLeft(2, "0")
- hh = Mid(pHeure, 1, x1 - 1).PadLeft(2, "0")
- End If
-
- Return hh + mm
- Else
- Return "0000"
- End If
- End Function
Public Function DateDBToPage(ByVal pDate As String) As String
' Composition d'une date de base de donnée style AAAAMMJJ vers JJ/MM/AAAA
If pDate.Length = 8 Then
Return Mid(pDate, 7, 2) + "/" + Mid(pDate, 5, 2) + "/" + Mid(pDate, 1, 4)
Else
Return ""
End If
End Function
Public Function HeureDBToPage(ByVal pHeure As String) As String
' Composition d'une Heure de base de donnée style HHMM vers HH:MM
If pHeure.Length = 4 Then
Return Mid(pHeure, 1, 2) + ":" + Mid(pHeure, 3, 2)
Else
Return ""
End If
End Function
' -------------------------------------------------------------------------------
Public Function DatePageToDb(ByVal pDate As String) As String
' -------------------------------------------------------------------------------
' Composition d'une date JJ/MM/AAAA pour une base de donnée style AAAAMMJJ
If pDate.Length >= 8 Then
Dim x1 As Integer = pDate.IndexOf("/") + 1 ' Récup position du premier "/"
Dim x2 As Integer = pDate.IndexOf("/", x1 + 1) + 1 ' Récup position du deuxième "/"
Dim aaaa, mm, jj As String
aaaa = Mid(pDate, x2 + 1, pDate.Length - x2)
If aaaa.Length = 2 Then aaaa = "20" + aaaa ' On vérifie si une date sur 2 position on complète avec 20xx
aaaa = aaaa.PadLeft(4, "0")
mm = Mid(pDate, x1 + 1, x2 - x1 - 1).PadLeft(2, "0")
jj = Mid(pDate, 1, x1 - 1).PadLeft(2, "0")
Return aaaa + mm + jj
Else
Return ""
End If
End Function
' -------------------------------------------------------------------------------
Public Function HeurePageToDb(ByVal pHeure As String) As String
' -------------------------------------------------------------------------------
' Composition d'une heure HH:MM pour une base de donnée style HHMM
If pHeure.Length >= 3 Then
Dim x1 As Integer = pHeure.IndexOf(":") + 1 ' Récup position du ":"
Dim x2 As Integer = pHeure.Length
Dim hh, mm As String
If x1 < 0 Then
' Il n'y à pas de ':' dans l'heure on la justifie comme ca sur 4 positions
hh = Format(Int(pHeure), "0000")
Return hh
Else
mm = Mid(pHeure, x1 + 1, x2 - x1).PadLeft(2, "0")
hh = Mid(pHeure, 1, x1 - 1).PadLeft(2, "0")
End If
Return hh + mm
Else
Return "0000"
End If
End Function
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
ASYNC/AWAIT: COMPRENDRE COMMENT CA MARCHEASYNC/AWAIT: COMPRENDRE COMMENT CA MARCHE par fathi
Tout le monde est unanime pour dire que la programmation multi-thread et asynchrone est en train de devenir un sujet incontournable. Beaucoup de choses sont arrivées avec le framework 4 pour le code parallèle (TPL, PLinq,.) et bientôt, on va avoir l...
Cliquez pour lire la suite de l'article par fathi PAS D'INTELLITRACE SUR MON SITE WEB DANS IIS !PAS D'INTELLITRACE SUR MON SITE WEB DANS IIS ! par Etienne Margraff
J'ai récemment eu un problème pour obtenir l'intelliTrace sur un site web dans IIS. Il n'y avait pas de message d'erreur, rien dans le journal d'évènement Windows, et après 3 appels à une voyante, 2 visites chez un marabou, j'ai failli me résign...
Cliquez pour lire la suite de l'article par Etienne Margraff OFFICE 365 - SHAREPOINT ONLINE, QUELQUES LIMITATIONSOFFICE 365 - SHAREPOINT ONLINE, QUELQUES LIMITATIONS par junarnoalg
De nombreuses entreprises font le choix de SharePoint Online, service fourni au travers de l'offre de Microsoft Office 365. S'il est vrai que ce choix apporte un grand nombre d'avantages; rapidité de mise en ½uvre, disponibilité, large couvertu...
Cliquez pour lire la suite de l'article par junarnoalg PRéSENTATION DES API REST DE WINDOWS AZURE : LISTER LES COMPTES DE STORAGEPRéSENTATION DES API REST DE WINDOWS AZURE : LISTER LES COMPTES DE STORAGE par richardc
http://www.c2idotnet.com/articles/presentation-des-api-rest-de-windows-azure-lister-les-comptes-de-storage
Désolé pour "toto", mais c2i existait avant blogs.developpeur.org et c'est mon site "officiel" ;-) ...
Cliquez pour lire la suite de l'article par richardc
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|