Solved

sql select statement

Posted on 2012-03-12
3
364 Views
Last Modified: 2012-08-13
I have this select statement.  I'm trying to restrict the returned te.Training_Date to be no later than 1/1/2011.  I"m not able to get this part (where te.Training_Date <= 1/1/2011 12:00:00)) of my syntax to work correctly.  The Training Date has smalldatetime datatype.
 
SQL = "Select Training_Events_ID, tc.Training_Area, te.Class_Title, te.Training_Date, te.Training_Hours from Training_Events te, Training_Category tc where te.Training_Date <= 1/1/2011 12:00:00) and te.Training_Category_ID = tc.Training_Category_ID and Staff_Training_ID = " & lv_Staff_Training_ID & " Order by te.Training_Date;"

Open in new window


Thanks for looking at this.
0
Comment
Question by:ocdc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 37708636
Try

SQL = "Select Training_Events_ID, tc.Training_Area, te.Class_Title, te.Training_Date, te.Training_Hours from Training_Events te, Training_Category tc where te.Training_Date <= '1-jan-2011' and te.Training_Category_ID = tc.Training_Category_ID and Staff_Training_ID = " & lv_Staff_Training_ID & " Order by te.Training_Date;"


Kelvin
0
 
LVL 32

Expert Comment

by:Ephraim Wangoya
ID: 37708640
try

SQL = "Select Training_Events_ID, tc.Training_Area, te.Class_Title, te.Training_Date te.Training_Hours from Training_Events te inner join Training_Category tc on te.Training_Category_ID = tc.Training_Category_ID where te.Training_Date <= '20110101'  
and Staff_Training_ID = " & lv_Staff_Training_ID & " Order by te.Training_Date;"

Open in new window

0
 

Author Closing Comment

by:ocdc
ID: 37708648
Thanks for the quick help.  Worked great.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CAST issue with SQL 2000 15 42
ms sql and asp dates 5 42
Any benefit to adding a Clustered index here? 4 36
How to create and use encrypted columns in SQL 2005? 15 59
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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 set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

737 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