Foxtable(狐表)用户栏目专家坐堂 → 【问题解决,但是有了新的问题】请问大家:如何找出标记了的客户最近一次拜访日期,请看例子


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

主题:【问题解决,但是有了新的问题】请问大家:如何找出标记了的客户最近一次拜访日期,请看例子

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/10/5 19:42:00 [显示全部帖子]

 参考下面的代码

Dim filter As String = "标记 = true and 日期 <= #" & Date.Today.AddDays(-5) & "#"
Dim count As Integer = DataTables("表A").Compute("count(_Identify)", filter)
msgbox(count)
Tables("表A").Filter = filter

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/10/5 21:36:00 [显示全部帖子]

 参考代码

Dim dt As DataTable = DataTables("表A")
Dim names As List(Of String) = dt.GetUniqueValues("姓名 is not null", "姓名")
Dim count As Integer = 0
For Each name As String In names
    Dim fdr As DataRow = dt.Find("姓名 = '" & name & "'", "日期 desc")
    If fdr IsNot Nothing AndAlso fdr("日期") <= Date.Today.AddDays(-5) Then
        count += 1
    End If
Next
msgbox(count)

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/10/6 10:50:00 [显示全部帖子]

 回复6楼

Dim dt As DataTable = DataTables("表A")
Dim names As List(Of String) = dt.GetUniqueValues("姓名 is not null", "姓名")
Dim count As Integer = 0
Dim idxs As String = ""
For Each name As String In names
    Dim fdr As DataRow = dt.Find("姓名 = '" & name & "'", "日期 desc")
    If fdr IsNot Nothing AndAlso fdr("日期") <= Date.Today.AddDays(-5) Then
        count += 1
        idxs += fdr("_identify") & ","
    End If
Next
msgbox(count)
If count > 0 Then
    Tables(dt.Name).Filter = "_identify in (" & idxs.Trim(",") & ")"
End If

 回到顶部