|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi i have database wher Date stored in following format 19.06.2009 8:26:00 in the two diferent fields.
now i try make query to get right data Dim day1 As String GOOD = Chr(35) '# day1 = Format(DTPicker1.value, "mm-dd-yy") RecordSQL = "SELECT * FROM " & GPSvorm.basename.Text & " WHERE start_d LIKE " & GOOD & day1 & GOOD & " OR end_d LIKE " & GOOD & day1 & GOOD & " ORDER BY [ID] DESC" All thoes day formats what i use in query work when they are stored in the database in the same format. But in this case i need find all dates no matter what time behind the date. Something like 19.06.2009* Last edited by backup69 : June 26th, 2009 at 05:21 AM. |
|
#2
|
||||
|
||||
|
Why are you storing dates like this? What type of database is this? Is there not a Date datatype?
|
|
#3
|
|||
|
|||
|
This is stored like Date Date/Time (General Date) in the Acess database
|
|
#4
|
||||
|
||||
|
Use the DateValue() function to pull out just the actually day and ignore the time.
|
|
#5
|
|||
|
|||
|
i tried :
RecordSQL = "SELECT * FROM " & GPSvorm.basename.Text & " WHERE start_d LIKE " & GOOD & DateValue(day1) & GOOD & " ORDER BY [ID] DESC" got error RecordSQL = "SELECT * FROM " & GPSvorm.basename.Text & " WHERE start_d LIKE '" & GOOD & DateValue(day1) & GOOD & "' ORDER BY [ID] DESC" got error RecordSQL = "SELECT * FROM " & GPSvorm.basename.Text & " WHERE start_d LIKE '" & DateValue(day1) & "' ORDER BY [ID] DESC" got nothing Dont know how solve this |
|
#6
|
||||
|
||||
|
Quote:
if your dates are dates, and not text, then you should not use LIKE if your dates have non-zero time components, then in order to find all the values for a specific day, you need to use a range test e.g. to find the rows for june 27th, you would use Code:
WHERE start_d >= #2009-06-27# AND start_d < #2009-06-28# |
|
#7
|
|||
|
|||
|
Thank you
this is help me a lot and now i know how go forward with this. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Using LIKE operator to search date |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|