AW: Datum z.B.nur Monat Jahr
24.01.2008 20:13:00
Erich
Hallo Horst,
interessiert dich, wie VBA dieses merkwürdige Datum ausrechnet?
Dann auf einem leeren Tabellenblatt:
Sub Datümer()
Dim datD As Date, strD As String, lngD As Long
Columns(2).NumberFormat = "@"
Range("A1:D1") = Split("Date String Long Date")
datD = DateValue("24.01.2008")
Cells(3, 1) = datD
strD = Format(datD, "dd/yyyy")
Cells(3, 2) = strD
lngD = CLng(strD)
Cells(3, 3) = lngD
datD = CDate(lngD)
Cells(3, 4) = datD
datD = DateValue("24.01.2008")
Cells(5, 1) = datD
strD = Format(datD, "mm/yyyy")
Cells(5, 2) = strD
lngD = CLng(strD)
Cells(5, 3) = lngD
datD = CDate(lngD)
Cells(5, 4) = datD
datD = DateValue("24.01.2008")
Cells(7, 1) = datD
strD = Format(datD, "d/m/yy")
Cells(7, 2) = strD
lngD = CLng(strD)
Cells(7, 3) = lngD
datD = CDate(lngD)
Cells(7, 4) = datD
datD = DateValue("24.01.2008")
Cells(9, 1) = datD
lngD = CLng(datD)
Cells(9, 3) = lngD
datD = CDate(lngD)
Cells(9, 4) = datD
End Sub
Dabei kommt dann folgendes raus:
| A | B | C | D |
1 | Date | String | Long | Date |
2 | | | | |
3 | 24.01.2008 | 24.2008 | 242008 | 04.08.2562 |
4 | | | | |
5 | 24.01.2008 | 01.2008 | 12008 | 15.11.1932 |
6 | | | | |
7 | 24.01.2008 | 24.1.08 | 24108 | 01.01.1966 |
8 | | | | |
9 | 24.01.2008 | | 39471 | 24.01.2008 |
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort