Foxtable(狐表)用户栏目专家坐堂 → 字符型日期数据整理


  共有3518人关注过本帖树形打印复制链接

主题:字符型日期数据整理

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:111393 积分:567029 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/19 22:29:00 [显示全部帖子]

Dim t As Table = Tables("A")
t.sort = "日期"
Dim ym As String  = format(t.rows(0)("日期"),"yyyy-MM")
Dim str As String = ym & "(" & t.rows(0)("日期").day & ","
For i As Integer = 1 To t.rows.count - 1
    If ym = format(t.rows(i)("日期"),"yyyy-MM")Then
        str = str & t.rows(i)("日期").day & ","
    Else
        ym = format(t.rows(i)("日期"),"yyyy-MM"
        str = str.trim(",") & ")," & ym & "("& t.rows(i)("日期").day & ","
    End If
Next
str = str.Trim(",") & ")"
msgbox(str)

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:111393 积分:567029 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/4/20 10:33:00 [显示全部帖子]

Dim t As Table = Tables("A")
For k As Integer = 0 To t.rows.count - 1
    Dim lst As new List(of Date)
    For Each s As String In t.rows(k)("日期").split(",")
        lst.add(cdate(s.trim))
    Next
    lst.sort()
    Dim ym As String  = format(lst(0),"yyyy-MM")
    Dim str As String = ym & "(" & lst(0).day & ","
    For i As Integer = 1 To lst.count - 1
        If ym = format(lst(i),"yyyy-MM") Then
            str = str & lst(i).day & ","
        Else
            ym = format(lst(i),"yyyy-MM")
            str = str.trim(",") & ")," & ym & "(" & lst(i).day & ","
        End If
    Next
    str = str.Trim(",") & ")"
    msgbox(str)
Next

 回到顶部