Created
June 2, 2010 18:58
-
-
Save gsherman/422816 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Declare Function GetStartingDateOfLastMonth() as Date | |
Declare Function GetStartingDateOfThisMonth() as Date | |
Declare Sub FindCasesCreatedLastMonth() | |
Sub main() | |
Call FindCasesCreatedLastMonth | |
End Sub | |
Sub FindCasesCreatedLastMonth() | |
Dim br as New Bulkretrieve | |
Dim casesList as List | |
startDate = GetStartingDateOfLastMonth() | |
endDate = GetStartingDateOfThisMonth | |
Debug.Print "Finding cases from " & cstr(startDate) & " to " & cstr(endDate) | |
br.SimpleQuery 0, "case" | |
br.AppendFilter 0, "creation_time", cbGreaterOrEqual, cstr(startDate) | |
br.AppendFilter 0, "creation_time", cbLess, cstr(endDate) | |
br.RetrieveRecords | |
Set casesList = br.GetRecordList(0) | |
Debug.Print "Found " & cstr(casesList.Count) & " cases." | |
End Sub | |
Function GetStartingDateOfLastMonth() as Date | |
Dim today as String | |
Dim oneMonthAgo as Date | |
Dim lastMonth as Integer | |
Dim yearOfLastMonth as Integer | |
today = App.CurrentDate | |
oneMonthAgo = DateAdd("m", -1, today) | |
lastMonth = Month(oneMonthAgo) | |
If Len(cstr(lastMonth)) = 1 Then lastMonth = "0" & lastMonth | |
yearOfLastMonth = Year (oneMonthAgo) | |
GetStartingDateOfLastMonth = CDate(lastMonth & "-01-" & yearOfLastMonth) | |
End Function | |
Function GetStartingDateOfThisMonth() as Date | |
Dim today as String | |
Dim thisMonth as Integer, thisYear as Integer | |
today = App.CurrentDate | |
thisMonth = Month(today) | |
thisYear = Year(today) | |
If Len(cstr(thisMonth)) = 1 Then thisMonth = "0" & thisMonth | |
GetStartingDateOfThisMonth = CDate(thisMonth & "-01-" & thisYear) | |
End Function | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment