以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 字符型日期数据整理 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=148938) |
||||||
-- 作者:飞云 -- 发布时间:2020/4/19 12:11:00 -- 字符型日期数据整理 老师您好,请问日期列(2010-04-28,2020,04-29,2020-04-30,2020-05-01,2020-05-02 数据不固定,根据筛选生成)想整理成(2010-04(28,29,30),2010-05(01,02)),如何做,谢谢您! |
||||||
-- 作者:有点蓝 -- 发布时间: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)
|
||||||
-- 作者:飞云 -- 发布时间:2020/4/20 10:13:00 -- 老师您好,表列如下:
|
||||||
-- 作者:有点蓝 -- 发布时间: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
|
||||||
-- 作者:飞云 -- 发布时间:2020/4/20 12:44:00 -- 谢谢老师!! |