设为首页收藏本站Access中国

Office中国论坛/Access中国论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

把日期转化为中文表示格式

1970-1-1 08:00| 发布者: huanghai『文章』| 查看: 2354| 评论: 0

应留言板中的网友:sxczw8211请求,写了这样的一个函数.

'函数功能:把日期转化为中文表示格式
'使用方法:
'Print date_w2e("2004-12-31")
'二〇〇四年十二月三十一日
Function date_w2e(ByVal myDate As Date) As String
    Dim eDate As String
    Dim intY, intM, intD As Integer
    Dim intD2 As Integer
    Dim I As Integer

    intY = Year(myDate)
    intM = Month(myDate)
    intD = Day(myDate)

    For I = 1 To Len(intY)
        eDate = eDate & number_w2e(Mid(intY, I, 1))
    Next
    eDate = eDate & "年"

    eDate = eDate & number_w2e(intM)
    eDate = eDate & "月"

    Select Case intD
    Case 1 To 9, 10, 20, 30
        eDate = eDate & number_w2e(intD)
    Case 11 To 19
        eDate = eDate & number_w2e(10) & number_w2e(Mid(intD, 2, 1))
    Case 21 To 29
        eDate = eDate & number_w2e(20) & number_w2e(Mid(intD, 2, 1))
    Case 31
        eDate = eDate & number_w2e(30) & number_w2e(1)
    End Select
    eDate = eDate & "日"

    date_w2e = eDate
End Function
Function number_w2e(ByVal I As Integer) As String
    Select Case I
    Case 0
        number_w2e = "〇"
    Case 1
        number_w2e = "一"
    Case 2
        number_w2e = "二"
    Case 3
        number_w2e = "三"
    Case 4
        number_w2e = "四"
    Case 5
        number_w2e = "五"
    Case 6
        number_w2e = "六"
    Case 7
        number_w2e = "七"
    Case 8
        number_w2e = "八"
    Case 9
        number_w2e = "九"
    Case 10
        number_w2e = "十"
    Case 11
        number_w2e = "十一"
    Case 12
        number_w2e = "十二"
    Case 20
        number_w2e = "二十"
    Case 30
        number_w2e = "三十"
    End Select
End Function

最新评论

QQ|站长邮箱|小黑屋|手机版|Office中国/Access中国 ( 粤ICP备10043721号-1 )  

GMT+8, 2025-4-4 05:17 , Processed in 0.083488 second(s), 17 queries .

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

返回顶部