日期转换
有4个十六进制的数来代表日期,如下:
18 40 32 01 = 2007/4/24
14 40 32 01 = 2007/4/20
BA 3F 32 01 = 2007/3/30
68 2D 31 01 = 2001/1/4
69 2D 31 01 = 2001/1/5
1E F5 31 01 = 2005/12/30
C8 17 32 01 = 2006/1/4
请问怎样从十六进制的数转换成日期。
[解决办法]
举例太少
难以看出规律来
[解决办法]
Private Sub Command1_Click()
Dim s As String
s = "18 40 32 01 "
MsgBox fm(s)
s = "BA 3F 32 01 "
MsgBox fm(s)
End Sub
Private Function fm(ByVal s As String) As String
Dim temp As String
Dim arr
arr = Split(s, " ")
Dim i As Long
For i = UBound(arr) To 0 Step -1
temp = temp & arr(i)
Next
i = CLng( "&H " & temp)
temp = CStr(i)
'这里你用format或其他方法格式化字串也可
fm = Left(temp, 4) + "- " + Mid(temp, 5, 2) + "- " + Right(temp, 2)
End Function
[解决办法]
这是什么日期格式?从没有见过,呵呵,学到了
[解决办法]
厉害 学习中
[解决办法]
怪癖的日期,我也来一个办法
Private Declare Sub CopyMemory Lib "kernel32 " Alias "RtlMoveMemory " (Destination As Any, Source As Any, ByVal Length As Long)
Private Function ByteToDateStr(bytDate() As Byte) As String
Dim i As Long
CopyMemory i, bytDate(0), 4
ByteToDateStr = CStr(i \ 10000) & "/ " & CStr((i \ 100) Mod 100) & "/ " & CStr(i Mod 100)
End Function
Private Sub Form_Load()
Dim s As String, a(3) As Byte
'18 40 32 01 = 2007/4/24
a(0) = &H18
a(1) = &H40
a(2) = &H32
a(3) = &H1
s = ByteToDateStr(a)
Debug.Print s
'C8 17 32 01 = 2006/1/4
a(0) = &HC8
a(1) = &H17
a(2) = &H32
a(3) = &H1
s = ByteToDateStr(a)
Debug.Print s
'1E F5 31 01 = 2005/12/30
a(0) = &H1E
a(1) = &HF5
a(2) = &H31
a(3) = &H1
s = ByteToDateStr(a)
Debug.Print s
End Sub
[解决办法]
听课...
[解决办法]
第一次见到,五星上将就是厉害啊,学习中
[解决办法]
将日期转成16进制
20070424=1324018
20070420=1324014
20070330=1323FBA
20010104=1315478
20010105=1315479
20051230=131F51E
20060104=013217C8
如果有规律那么
以下两个有误吧
68 2D 31 01 = 2001/1/4
69 2D 31 01 = 2001/1/5
应该是2000/1/4和2000/1/5
[解决办法]
学习
[解决办法]
日期用得着这样写吗?