Sub Get_Format_Date (ParFecha As Long, ParFormato As String)
Dim lcResultado As String
lcResultado = ""
'
Select ParFormato
Case "YYYYMMDD"
lcResultado = NumberFormat2(DateTime.GetYear(ParFecha),4,0,0,False) & _
NumberFormat2(DateTime.GetMonth(ParFecha),2,0,0,False) & _
NumberFormat2(DateTime.GetDayOfMonth(ParFecha),2,0,0,False)
Case "YYYYMMDD HHMMSS"
lcResultado = NumberFormat2(DateTime.GetYear(ParFecha),4,0,0,False) & _
NumberFormat2(DateTime.GetMonth(ParFecha),2,0,0,False) & _
NumberFormat2(DateTime.GetDayOfMonth(ParFecha),2,0,0,False) & " " & _
NumberFormat2(DateTime.GetHour(ParFecha),2,0,0,False) & _
NumberFormat2(DateTime.GetMinute(ParFecha),2,0,0,False) & _
NumberFormat2(DateTime.GetSecond(ParFecha),2,0,0,False)
Case "YYYY-MM-DD HH:MM:SS"
lcResultado = NumberFormat2(DateTime.GetYear(ParFecha),4,0,0,False) & "-" & _
NumberFormat2(DateTime.GetMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetDayOfMonth(ParFecha),2,0,0,False) & " " & _
NumberFormat2(DateTime.GetHour(ParFecha),2,0,0,False) & ":" & _
NumberFormat2(DateTime.GetMinute(ParFecha),2,0,0,False) & ":" & _
NumberFormat2(DateTime.GetSecond(ParFecha),2,0,0,False)
Case "DD-MM-YYYY"
lcResultado = NumberFormat2(DateTime.GetDayOfMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetYear(ParFecha),4,0,0,False)
Case "DD-MM-YYYY HH:MM:SS"
lcResultado = NumberFormat2(DateTime.GetDayOfMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetYear(ParFecha),4,0,0,False) & " " & _
NumberFormat2(DateTime.GetHour(ParFecha),2,0,0,False) & ":" & _
NumberFormat2(DateTime.GetMinute(ParFecha),2,0,0,False) & ":" & _
NumberFormat2(DateTime.GetSecond(ParFecha),2,0,0,False)
Case "DD-MM-YYYY HH:MM"
lcResultado = NumberFormat2(DateTime.GetDayOfMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetMonth(ParFecha),2,0,0,False) & "-" & _
NumberFormat2(DateTime.GetYear(ParFecha),4,0,0,False) & " " & _
NumberFormat2(DateTime.GetHour(ParFecha),2,0,0,False) & ":" & _
NumberFormat2(DateTime.GetMinute(ParFecha),2,0,0,False)
Case Else
lcResultado = ""
' Msgbox("Formato de Fecha Invalido", "ERROR")
End Select
'
Return lcResultado
End Sub