datagridview 中的日期操作

Date manipulation in datagridview

抱歉,vbNET 新手。
我有关于数据库中日期操作的问题。
我想加载一个数据库,其中保存日期超过 40 天。
我想使用按钮加载它。
这是我输入的代码。

Private Sub BtnPenalty_Click(ByVal sender As System.Object, 
ByVal e As System.EventArgs) Handles BtnPenalty.Click

    If (CbxSort.Text = "Transaction Date") Then
        Srt = "[CCCD Loading Database]"
    ElseIf (CbxSort.Text = "Unit Number") Then
        Srt = "F2"
    ElseIf (CbxSort.Text = "Category") Then
        Srt = "F3"
    ElseIf (CbxSort.Text = "Type Length") Then
        Srt = "F5"
    ElseIf (CbxSort.Text = "T-State") Then
        Srt = "F6"
    ElseIf (CbxSort.Text = "Position") Then
        Srt = "F7"
    ElseIf (CbxSort.Text = "I/B Actual Visiting") Then
        Srt = "F8"
    ElseIf (CbxSort.Text = "Fright Kind") Then
        Srt = "F9"
    End If


    Try
        FillDGView("SELECT [CCCD Loading Database] AS [Transaction Date], [F2] AS [Unit Number], [F3] AS [Category], " & _
                  " [F4] AS [Temp Required (C)], [F5] AS [Type Length], [F6] AS [T-State], [F7] AS [Position], [F8] AS [I/B Actual Visit], " & _
                  " [F9] AS [Fright Kind] FROM [Loading$] ORDER BY " & Srt & "  ")

        LblList.Text = "Penalty List"

    Catch ex As Exception
        MsgBox(ex.Message, MsgBoxStyle.Critical, Text)

    End Try

End Sub

如果您正在使用 SQL 服务器使用 DATEDIFF 函数,那么 where 子句将是

WHERE datediff(d,  [Transaction Date], getdate()) > 40