Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Having problem with datetime column in query

Author  Topic 

Ish
Starting Member

11 Posts

Posted - 2010-07-26 : 13:02:15
Hi

SELECT tblAppointment.appointmentId, tblAppointment.userId, tblAppointment.appointmentDate,
tblAppointment.sTimeId, tblAppointment.note, tblAppointment.created, tblAppointment.createdBy
WHERE (tblAppointment.userId) = " & myStaffId _
AND ((tblAppointment.appointmentDate) >= " & myStartDateUS _
AND (tblAppointment.appointmentDate) <= " & myEndDateUS & ")"

I have above query in my ASP page.

myStaffId = 1
myStartDateUS = '2010-7-26'
myEndDateUS = '2010-7-31'

I have table tblAppointment, column appointmentDate is define as datetime.

I have many record in the table, but when I execute a this query, i am not get any result back.

Please can some one help to sort this.

many thanks

Kristen
Test

22859 Posts

Posted - 2010-07-26 : 13:13:21
Pass the date as yyyymmdd - no hyphens.

Wrap it with single quotes.

AND ((tblAppointment.appointmentDate) >= '" & myStartDateUS & "'"_
AND (tblAppointment.appointmentDate) <= '" & myEndDateUS & "')"


Does that fix it?
Go to Top of Page
   

- Advertisement -