YYYYWWD 表示2008322 表示 2008年的第32周星期二 等价于 2008-08-05
当 YYYYMMDD -> YYYYWWD 比较好转
但是当 YYYYWWD ->YYYYMMDD 想了好久没想出来。求教啊

解决方案 »

  1.   


    先求出 2008-1-1 的 YYYYWWW 格式,其他的不用我教你了吧。
      

  2.   

    YYYYWWD ->YYYYMMDD 
    我想2008322转成于 2008-08-05
      

  3.   


    闷鼓只好下重锤了:Dim strWWW As String, strTmp As String
    Dim datFirstDate As Date, datMyDate As DatestrWWW = "2008323"datFirstDate = CDate(Left(strWWW, 4) & "-1-1")
    strTmp = Format(datFirstDate, "yyyywww") '注意,d 得到日期,w 才得到星期号
    datMyDate = datFirstDate + (Val(Mid(strWWW, 5, Len(strWWW) - 5)) - 1) * 7 + Val(Right(strWWW, 1)) - Val(Right(strTmp, 1))MsgBox datMyDate
      

  4.   

    单纯的format做不到。思路和3楼差不多。Dim strWWW As String, strRet As String
    Dim datFirstDate As Date, datMyDate As Date
    strWWW = "2008323"datFirstDate = CDate(Left(strWWW, 4) & "-1-1") 
    mydate=dateadd(d,right(strWWW,1),dateadd("ww",mid(strWWW, 5,2)-1,datFirstDate))
    strRet=format(mydate,"yyyy-mm-dd")
      

  5.   

    循环一天天加,再比较,好懂点吧:    Dim dw As String
        Dim dt As String
        
        dw = "2008322"
        dt = Left(dw, 4) & "-1-1"
        Do
            If Format(dt, "yyyywww", vbMonday) = dw Then Exit Do
            dt = DateAdd("d", 1, dt)
        Loop
                
        MsgBox dt