Skip to main content
Inspiring
June 25, 2008
Question

Ms Access - Valid Query?? -Urgent

  • June 25, 2008
  • 1 reply
  • 285 views
Hi all,
Select Id from schedule where #06/23/08 10:30 PM# between sch_date + ' ' +sch_time_start And sch_date + ' ' + sch_time_end;

Is above a valid statement ? if Not how would I fixed it. sch_date and sch_time_start are dateformat in ms access.
This topic has been closed for replies.

1 reply

Inspiring
July 1, 2008
Technically, it's valid, but it's not very good.

Step 1 - store dates and times as dates and times, not strings.

Step 2 - convert this string, "06/23/08 10:30 PM", to a datetime variable using date functions.

Step 3 - adopt this style of writing sql.
where field_name
operator or keyword
value

In other words, instead of
where 1 = myfieldname
use
where myfieldname = 1

In your specific case, it would be
where sch_datetime_start >= some_value
and sch_datetime_end < some_value