Solved

sql select statement

Posted on 2012-03-12
3
351 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
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:ewangoya
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now