Hello all,
I'm trying to compare a time in date/time format to another time and check if ist bigger. The time comes from a query in which one column calls the function. The Function looks like this:
The first query saved in strSQL does never return a result. The query printed looks like this:
The tables Shifts and the query looks like this. The "Buchungsdatum" and "Istende" column contain the date and the time.
I guess it's just a syntax error but i can't get my head around where it is.
Would appreciate any help
Best Michael
I'm trying to compare a time in date/time format to another time and check if ist bigger. The time comes from a query in which one column calls the function. The Function looks like this:
Code:
Public Function getShifDate(shiftType As Integer, datex As Date, timex As Date, loc As Integer) As Date
Dim weekdaynum As Integer
Dim weekdaynum2 As Integer
Dim datetimex As Date
Dim inRange As Long
Dim strSQL As String
Dim strSQL2 As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
datetimex = datex + timex
weekdaynum = weekday(datetimex, vbMonday)
If weekaynum = 7 Then
weekdaynum2 = 1
End If
strSQL = "SELECT Max(ID) " _
& "FROM Shifts " _
& "WHERE ShiftType = " & shiftType & " " _
& "AND Weekdaynumber = " & weekdaynum & " " _
& "AND Werk = " & loc & " " _
& "AND Start < #" & timex & "# ;"
strSQL2 = "SELECT Max(ID) " _
& "FROM Shifts " _
& "WHERE ShiftType = " & shiftType & " " _
& "AND Weekdaynumber = " & weekdaynum2 & " " _
& "AND Werk = " & loc & ";"
Debug.Print strSQL
Debug.Print strSQL2
Set rs = db.OpenRecordset(strSQL)
If rs.Fields.Count = 0 Then
Set rs = db.OpenRecordset(strSQL)
getShifDate = datex
Else
getShifDate = DateAdd("d", -1, datex)
End If
The first query saved in strSQL does never return a result. The query printed looks like this:
Code:
SELECT Max(ID) FROM Shifts WHERE ShiftType = 3 AND Weekdaynumber = 2 AND Werk = 2101 AND Start < #13:08:14# ;
The tables Shifts and the query looks like this. The "Buchungsdatum" and "Istende" column contain the date and the time.
I guess it's just a syntax error but i can't get my head around where it is.
Would appreciate any help
Best Michael