Solved

sql select statement

Posted on 2012-03-12
3
355 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

863 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

28 Experts available now in Live!

Get 1:1 Help Now