Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 26th, 2009, 05:19 AM
backup69 backup69 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Estonia
Posts: 62 backup69 User rank is Private First Class (20 - 50 Reputation Level)backup69 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 32 m 19 sec
Reputation Power: 5
Question Using LIKE operator to search date

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.

Reply With Quote
  #2  
Old June 26th, 2009, 07:53 AM
jzd's Avatar
jzd jzd is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2007
Posts: 933 jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 14 h 13 m 6 sec
Reputation Power: 792
Why are you storing dates like this? What type of database is this? Is there not a Date datatype?

Reply With Quote
  #3  
Old June 26th, 2009, 08:13 AM
backup69 backup69 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Estonia
Posts: 62 backup69 User rank is Private First Class (20 - 50 Reputation Level)backup69 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 32 m 19 sec
Reputation Power: 5
This is stored like Date Date/Time (General Date) in the Acess database

Reply With Quote
  #4  
Old June 26th, 2009, 08:22 AM
jzd's Avatar
jzd jzd is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2007
Posts: 933 jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level)jzd User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 14 h 13 m 6 sec
Reputation Power: 792
Use the DateValue() function to pull out just the actually day and ignore the time.

Reply With Quote
  #5  
Old June 26th, 2009, 08:31 AM
backup69 backup69 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Estonia
Posts: 62 backup69 User rank is Private First Class (20 - 50 Reputation Level)backup69 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 32 m 19 sec
Reputation Power: 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

Reply With Quote
  #6  
Old June 26th, 2009, 10:35 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 20,691 r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level)r937 User rank is General 22nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 1 Week 3 Days 9 h 46 m 6 sec
Reputation Power: 2459
Quote:
Originally Posted by backup69
Dont know how solve this
start by realizing the LIKE is intended for character (text) datatypes only

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#
does this make sense?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book

Reply With Quote
  #7  
Old June 26th, 2009, 04:19 PM
backup69 backup69 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: Estonia
Posts: 62 backup69 User rank is Private First Class (20 - 50 Reputation Level)backup69 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 21 h 32 m 19 sec
Reputation Power: 5
Thank you

this is help me a lot and now i know how go forward with this.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Using LIKE operator to search date


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
Stay green...Green IT