Solved

select and dates?

Posted on 2000-04-17
8
132 Views
Last Modified: 2010-05-02
I have text box on my form
in the text box property I have format to date
when i do my select to query access database it doesn't find the record???
let say textdate.text is my textbox

do i do
select * from mydatabase where datefield=textdate.text


or do i have to do a cdate on that textbox?

the field in my access database is same as the format in my textbox

any ideas???
0
Comment
Question by:jerbell
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 9

Accepted Solution

by:
Ruchi earned 15 total points
ID: 2723221
Date values must be enclosed within # signs.

ie.
Select * from mydatabase where datefield = #textdate.text#

Hope this helps.

0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2723245
Date values must be enclosed within # signs.

ie.
Select * from mydatabase where datefield = #textdate.text#

Hope this helps.

0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2723255
The best way is to use the US format:

strsql = "select * from mydatabase where datefield = " & format(textdate.text, "mm/dd/yyyy")
0
 
LVL 1

Expert Comment

by:detiege
ID: 2723264
I prefer doing:

SELECT * FROM Table WHERE Datafield LIKE textdate.text



Try to put your query in a buffer and execute it:

Buff = "SELECT * FROM Table WHERE DateField LIKE '" & textdate.text & "'"

conn.Execute(Buff)

But be sure that your "DateField" and your "textdate.text" are in the same format ! ! ! ! !

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2723330
detiege,

You are new here! There is a rule that says not to post as an answer when other experts already began to answer. You don't have to lock question. The asker can always accept one of the comment as it's accepted answer because the asker has a button for it!

Also, you don't have to ensure the format when you send the date in the US format!
0
 
LVL 14

Expert Comment

by:wsh2
ID: 2725174
emoreau:

I wholeheartedly agree that specifying the date format is the way to go. As I live and work in the USA, the mm/dd/yyyy format is no problem for me.

However, here at EE I have read several comments from people working in other nonUS locales that maintain the date default is dd/mm/yyyy. All in all.. dates still get me confused <blush>.. are you certain that mm/dd/yyyy is always the default date format regardless of locale? (I tend to believe it can be overridden through system settings.. but of that I am not sure).
0
 
LVL 1

Expert Comment

by:detiege
ID: 2725676
Excuse me to lock the question !

It's just that i'm new.

0
 

Author Comment

by:jerbell
ID: 2726416
thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

17 Experts available now in Live!

Get 1:1 Help Now