Ok, so I've written a program that searches a database and I've run into a little issue with dates, it seems. The search function has the ability to search ranges - and a date range is one of those options.
The dates are assigned to variables, which will be used in my regular expression, thusly:
And my regular expression is this:
For some reason, it formats the DataBaseItem as, for example, 8/16/2011, where both the other dates have been formatted 16/8/2011. Why?
The dates are assigned to variables, which will be used in my regular expression, thusly:
Code:
If LCase(Sheets("Database").Cells(a, InCol).Value) <> "asap" Then
TempDate = FormatDateTime(Sheets("Database").Cells(a, InCol).Value, vbShortDate)
DataBaseItem = DateValue(TempDate)
End If
SearchItem = DateValue(SearchField.Value)
SearchItem2 = DateValue(SearchField2.Value)
And my regular expression is this:
Code:
If SearchItem <= DataBaseItem And SearchItem2 >= DataBaseItem Then
Sheets("Data Analysis").Cells(Returns, 1).Value = Sheets("Database").Cells(a, 1).Value
Sheets("Data Analysis").Cells(Returns, 2).Value = Sheets("Database").Cells(a, 2).Value
Sheets("Data Analysis").Cells(Returns, 3).Value = Sheets("Database").Cells(a, 20).Value
Sheets("Data Analysis").Cells(Returns, 4).Value = Sheets("Database").Cells(a, 11).Value
Sheets("Data Analysis").Cells(Returns, 5).Value = Sheets("Database").Cells(a, 10).Value
Sheets("Data Analysis").Cells(Returns, 6).Value = Sheets("Database").Cells(a, 8).Value
Sheets("Data Analysis").Cells(Returns, 7).Value = Sheets("Database").Cells(a, 18).Value
Sheets("Data Analysis").Cells(Returns, 8).Value = Sheets("Database").Cells(a, 17).Value
Sheets("Data Analysis").Cells(Returns, 9).Value = Sheets("Database").Cells(a, 77).Value
Returns = Returns + 1
End If
For some reason, it formats the DataBaseItem as, for example, 8/16/2011, where both the other dates have been formatted 16/8/2011. Why?