Date format in SQL stmnt

D

Dave

Hi

I am having a problem with a date foemrat in a SQL Stment.

My code is

Dim strFormattedDate As Date

strFormattedDate = Format(dteDayToCompare, "mm/dd/yy")

rsDate.Open "SELECT TimeHoursWorkedDate FROM tblTimeHoursWorked WHERE
EmpID = " & EmpID & " AND TimeHoursWorkedDate = #" & strFormattedDate
& "# ORDER BY TimeHoursWorkedDate", gstrEmpDataCon, adOpenKeyset,
adLockPessimistic
 
J

John W. Vinson

Hi

I am having a problem with a date foemrat in a SQL Stment.

My code is

Dim strFormattedDate As Date

strFormattedDate = Format(dteDayToCompare, "mm/dd/yy")

rsDate.Open "SELECT TimeHoursWorkedDate FROM tblTimeHoursWorked WHERE
EmpID = " & EmpID & " AND TimeHoursWorkedDate = #" & strFormattedDate
& "# ORDER BY TimeHoursWorkedDate", gstrEmpDataCon, adOpenKeyset,
adLockPessimistic

Dim it as String rather than as Date. The Format() function returns a string
result, and you need to concatenate a string into the SQL string.

Note that "having a problem" without indicating the nature of the problem or
the error message you're getting is a bit of a barrier toward getting an
answer.

John W. Vinson [MVP]
 
Top