• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 140
  • Last Modified:

select and dates?

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
jerbell
Asked:
jerbell
  • 2
  • 2
  • 2
  • +2
1 Solution
 
RuchiCommented:
Date values must be enclosed within # signs.

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

Hope this helps.

0
 
RuchiCommented:
Date values must be enclosed within # signs.

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

Hope this helps.

0
 
Éric MoreauSenior .Net ConsultantCommented:
The best way is to use the US format:

strsql = "select * from mydatabase where datefield = " & format(textdate.text, "mm/dd/yyyy")
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
detiegeCommented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
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
 
wsh2Commented:
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
 
detiegeCommented:
Excuse me to lock the question !

It's just that i'm new.

0
 
jerbellAuthor Commented:
thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now