Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Server Conversion Date Criteria Help needed.

Status
Not open for further replies.

nrugado

Programmer
Dec 10, 2002
42
0
0
US
Hello, I am migrating an ms access db to SQL server. The fields that automatically stored the date in access have been changed to smalldatetime or datetime format. I have several instances where I am using a list box to select the date for criteria in a query or using a manual data entry for cirteria. However, it does not seem to recognize the date part when there is a time associated with the field.

i.e. 1/1/02 is the date that I would like to pull data for.

Before I could either enter 1/1/02 in a dialog box or refer the form to a list box that had this value. This was the value that was stored in the table.
When I changed the field type it now stores 1/1/02 1:40:00PM in the field. The query is having problems pulling out the date as a date only without the time. There are no results being pulled even though there are several records for that "Date".

Does anyone have any suggestions on how to approach this issue?
 
You could use the left function like Left(date, 11) to cut the time off and only be left with the date part. You may have to do the same with the database field.

select ... where left(databasecolumnname,11) = listbox value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top