下面的代码可以将任意日期(1000-01-01------>9999-12-31)转换为汉字显示:
Private Sub Command1_Click()
MsgBox datename(Date)
End Sub
Function datename(ByVal mydate As Date) As String
Dim i As Long, d(3) As String, myyear As String
myyear = Format(mydate, "yyyy")
For i = 1 To 4
d(0) = d(0) & Mid("○一二三四五六七八九", CInt(Mid(myyear, i, 1)) + 1, 1)'' trans year to chinese character
Next
d(1) = "年" & MonthName(Month(mydate)) ''add month name in chinese as “十月”
d(2) = Choose(Day(mydate) \ 10 + 1, "", "十", "二十", "三十") & Mid(" 一二三四五六七八九", Day(mydate) Mod 10 + 1, 1) & "日"
d(3) = "," & WeekdayName(Weekday(mydate))''add weekday name in chinese as “星期三”
datename = Join(d, "") '' combine year,month and day,weekday
datename = Replace(datename, " ", "") '' avoid space in result
End Function