Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Ms Access - Valid Query?? -Urgent

Participant ,
Jun 25, 2008 Jun 25, 2008
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.
TOPICS
Database access
245
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 01, 2008 Jul 01, 2008
LATEST
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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources