創建查詢以僅從表中提取上個月的資料。我的任何研究都不走運,只是試圖僅從月份列中提取資料。該表包括以下欄位:月份、型別、完成和進行中
月份欄位列出一月、三月等。
僅嘗試在設計視圖欄位中添加條件。任何幫助,將不勝感激。謝謝你。
uj5u.com熱心網友回復:
它可能是:
Select
*
From
YourTable
Where
MonthFromInvariant([Month]) = (Month(Date()) 12 - 2) Mod 12 1;
使用函式:
' Returns the month number from the English month name.
' Abbreviated names are accepted.
' An ambigous abbreviation (i.e. "ju") will return the first match.
' Passing a non existing name or abbreviation will raise an error.
'
' For parsing localised month names, use function MonthValue.
'
' 2021-04-02. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function MonthFromInvariant( _
ByVal MonthName As String) _
As Integer
Const FirstMonth As Integer = MinMonthValue
Const LastMonth As Integer = MaxMonthValue
Dim Month As Integer
MonthName = Trim(MonthName)
If MonthName <> "" Then
For Month = FirstMonth To LastMonth
If InStr(1, MonthNameInvariant(Month, True), MonthName, vbTextCompare) = 1 Then
Exit For
End If
Next
End If
If Month > LastMonth Then
' Month could not be found.
Err.Raise DtError.dtTypeMismatch
Exit Function
End If
MonthFromInvariant = Month
End Function
' Returns the English month name for the passed month number.
' Accepted numbers are 1 to 12. Other values will raise an error.
' If Abbreviate is True, the returned name is abbreviated.
'
' 2015-11-25. Gustav Brock, Cactus Data ApS, CPH.
'
Public Function MonthNameInvariant( _
ByVal Month As Long, _
Optional ByVal Abbreviate As Boolean) _
As String
Const AbbreviatedLength As Integer = 3
Dim MonthName( _
MinMonthValue To _
MaxMonthValue) As String
Dim Name As String
If Not IsMonth(Month) Then
Err.Raise DtError.dtInvalidProcedureCallOrArgument
Exit Function
End If
' Non-localized (invariant) month names.
MonthName(1) = "January"
MonthName(2) = "February"
MonthName(3) = "March"
MonthName(4) = "April"
MonthName(5) = "May"
MonthName(6) = "June"
MonthName(7) = "July"
MonthName(8) = "August"
MonthName(9) = "September"
MonthName(10) = "October"
MonthName(11) = "November"
MonthName(12) = "December"
If Abbreviate = True Then
Name = Left(MonthName(Month), AbbreviatedLength)
Else
Name = MonthName(Month)
End If
MonthNameInvariant = Name
End Function
取自DateText.bas我的專案
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/324408.html
