Solved

Simple sql query

Posted on 2006-07-11
9
249 Views
Last Modified: 2009-07-29
I wanted to see if there was a record already in the timein row that matched the current date and the employeeid.  I realized I have my logic messed up.  Thanks for your help

objCmd.CommandText = "select recordid from employeehours where employeeid = '" & stremployeeid & "' and timein =  & CONVERT(datetime, '" & Date.Today  & "', 102)"
0
Comment
Question by:running32
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 17083850
I am not good on VB,

objCmd.CommandText = "select recordid from employeehours where employeeid = '" & stremployeeid & "' and CONVERT(varchar(8),timein,112) =  & CONVERT(datetime, '" & Date.Today  & "', 112)"
0
 
LVL 75

Assisted Solution

by:Aneesh Retnakaran
Aneesh Retnakaran earned 150 total points
ID: 17083867
objCmd.CommandText = "select recordid from employeehours where employeeid = '" & stremployeeid & "' and CONVERT(varchar(8),timein,112) =   CONVERT(datetime, GETDATE(), 112)"
0
 
LVL 42

Accepted Solution

by:
EugeneZ earned 300 total points
ID: 17083968
try:

objCmd.CommandText = "select recordid from employeehours where employeeid = '" & stremployeeid & "' and datediff(dd,timein,  GETDATE())=0"
---employeeid is integer or string
or if int:
objCmd.CommandText = "select recordid from employeehours where employeeid = " & stremployeeid & " and datediff(dd,timein,  GETDATE())=0"
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 29

Expert Comment

by:leonstryker
ID: 17084036
Whats the datatype of employeeid?
0
 

Author Comment

by:running32
ID: 17084067
time  is stored in the database as date and time.  I only want to compare the date 7/11/2006 10:00 AM .  I have a record in the database that matches but I keep getting no records returned.

Thanks
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 17084095
Did you look to see the parameters you are actually passing in?  Maybe stremployeeid is empty.
0
 

Author Comment

by:running32
ID: 17084191
Tested that stremployeeid is populated.
0
 
LVL 29

Assisted Solution

by:leonstryker
leonstryker earned 50 total points
ID: 17084221
Try running a simple SQL to make sure its not a VB issue:

objCmd.CommandText = "select COUNT(recordid) from employeehours where employeeid = " & stremployeeid
0
 

Author Comment

by:running32
ID: 17084414
Thanks so much got it now.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question