Foxtable(狐表)用户栏目专家坐堂 → 被这条规则搞的头大了,求方法!


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

主题:被这条规则搞的头大了,求方法!

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


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

 参考例子,就是循环每一行,判断啊

 

http://www.foxtable.com/help/topics/2476.htm

 

 


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


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

Dim d1 As Date = "2012-9-1"
Dim d2 As Date = "2010-9-1"
Dim n As Integer = 30 '未来30天
Dim idxs As String = ""
For Each dr As DataRow In DataTables("表A").Select("上牌日期 is not null")
    Dim dt As Date = dr("上牌日期")
    Dim dt1 As New Date(Date.Today.Year,dt.Month,dt.Day)
    Dim dt2 As  New Date(Date.Today.AddDays(n).Year,dt.Month,dt.Day)
    If (dt1 >= Date.Today AndAlso dt1 < Date.Today.AddDays(n)) OrElse (dt2 >= Date.Today AndAlso dt2 < Date.Today.AddDays(n)) Then
        If dt >= d1 Then
            Dim y As Integer = dt.Year - d1.Year
            If y = 2 OrElse y = 4 OrElse y >= 6 Then
                idxs &= dr("_Identify") & ","
            End If
        Else If dt > d2 AndAlso dt < d1 Then
            Dim y As Integer = dt.Year - d1.Year
            If y > 0 AndAlso y Mod 2 = 0 OrElse dt2.Year >= 2016 Then
                idxs &= dr("_Identify") & ","
            End If
        Else If dt < d2 Then
            Dim y As Integer = dt.Year - d1.Year
            If dt2.Year >= 2016 Then
                idxs &= dr("_Identify") & ","
            End If
        End If
    End If
Next
Tables("表A").Filter = "_Identify in (" & idxs.trim(",") & ")"

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


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

 我测试例子没问题,你是就着例子测试的么


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


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

2月29日的问题

 

Dim d1 As Date = "2012-9-1"
Dim d2 As Date = "2010-9-1"
Dim n As Integer = 30 '未来30天
Dim idxs As String = ""
For Each dr As DataRow In DataTables("表A").Select("上牌日期 is not null")
    Dim dt As Date = dr("上牌日期")
    Dim dt1 As Date
    Dim dt2 As Date
    If dt.month = 2 AndAlso dt.Day = 29 Then
        dt1 = new Date(Date.Today.Year,dt.Month,28)
        dt2 = New Date(Date.Today.AddDays(n).Year,dt.Month,28)
    Else
        dt1 = new Date(Date.Today.Year,dt.Month,dt.Day)
        dt2 = New Date(Date.Today.AddDays(n).Year,dt.Month,dt.Day)
    End If
   
    If (dt1 >= Date.Today AndAlso dt1 < Date.Today.AddDays(n)) OrElse (dt2 >= Date.Today AndAlso dt2 < Date.Today.AddDays(n)) Then
        If dt >= d1 Then
            Dim y As Integer = dt.Year - d1.Year
            If y = 2 OrElse y = 4 OrElse y >= 6 Then
                idxs &= dr("_Identify") & ","
            End If
        Else If dt > d2 AndAlso dt < d1 Then
            Dim y As Integer = dt.Year - d1.Year
            If y > 0 AndAlso y Mod 2 = 0 OrElse dt2.Year >= 2016 Then
                idxs &= dr("_Identify") & ","
            End If
        Else If dt < d2 Then
            Dim y As Integer = dt.Year - d1.Year
            If dt2.Year >= 2016 Then
                idxs &= dr("_Identify") & ","
            End If
        End If
    End If
Next
Tables("表A").Filter = "_Identify in (" & idxs.trim(",") & ")"


 回到顶部