Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I have answered some questions and have gotten answers for my questions. Anywhere you can do this on one page helps tremendously..."

Geography

Where in the world do Tek-Tips members come from?
ttuser4 (MIS)
21 Jun 12 13:42
i have this query in vb6 program:
sSQL = "SELECT Count([WDATE]) From WHOURS Where [EMPID]=" & EMPID & " AND (([WDATE] Between (" & STD & "-31) And (" & STD & "-1)));"

debug.print sSQL looks like:
SELECT Count([WDATE]) From WHOURS Where [EMPID]=154 AND (([WDATE] Between (7/01/12-31) And (7/01/12-1)));

it doesn't give me the right number, it gives me zero every time. i suspect this criteria format '(7/01/12-31)' is causing the problem.

for example, this query in ms access gives me the right count
SELECT Count([WDATE]) AS Expr1
FROM WHOURS
WHERE (((WHOURS.EMPID)=154) AND ((WHOURS.WDATE) Between (NOW()-31) And (NOW()-1)));

can you please help me to get proper format for vb6?
dhookom (Programmer)
21 Jun 12 13:47
The expression: 7/01/12-31
7 divided by 1 divided by 12 minus 31.

Have you attempted to create date values prior to the sSQL? Also, dates are typically delimited with # depending on the database engine.

Duane
Hook'D on Access
MS Access MVP

ttuser4 (MIS)
21 Jun 12 14:21
excellent, thanks.

this is the proper format:
sSQL = "SELECT Count([WDATE]) From WHOURS Where [EMPID]=" & EMPID & " AND [WDATE] Between #" & DM31 & "# And #" & DM1 & "#;"

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close