469,125 Members | 1,733 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,125 developers. It's quick & easy.

date problem

121 100+
Hi
i want to retieve all the records of a particular date where date is specifiedin mask edbox
i have writtencode lie this

rssearch.Open "select * from timesheet where date1= #" & mskfrom.Text & "#", con, adOpenDynamic, adLockOptimistic
but it does not work though the specified date is pesent in ms- access table
Jan 6 '08 #1
7 804
creative1
274 100+
Hi
i want to retieve all the records of a particular date where date is specifiedin mask edbox
i have writtencode lie this

rssearch.Open "select * from timesheet where date1= #" & mskfrom.Text & "#", con, adOpenDynamic, adLockOptimistic
but it does not work though the specified date is pesent in ms- access table
You need to format you date for access; May be in a variable and then pass in query
fromdate = Format$(mskfrom.Text , "m/dd/yy")
Jan 6 '08 #2
debasisdas
8,127 Expert 4TB
Try to use dtpicker instead of masked control, and format the date as per database format before passing to SQL string.
Jan 6 '08 #3
creative1
274 100+
Is this useful/effective to use datepicker for applications that are not allowed to use pointing devices?
Jan 6 '08 #4
daniel aristidou
491 256MB
"select * from timesheet where date1= #" & mskfrom.Text & "#" .
Why not try formating both dates like this,
"select * From timesheet where Format(Date1,'yyyymmdd') = " & Format(mskfrom.Text ,'yyyymmdd')
Jan 6 '08 #5
Killer42
8,435 Expert 8TB
... "select * From timesheet where Format(Date1,'yyyymmdd') = " & Format(mskfrom.Text ,'yyyymmdd')
Generally speaking, it's not a good idea to use a function in the WHERE clause. It may not matter if the database is small, but for a large one, no way!

You force the DBMS to read every record and format the value, just to decide whether to read the record. :(

Also, in this example I think you'd need single quotes around the test value.
Jan 7 '08 #6
Killer42
8,435 Expert 8TB
Something else to keep in mind. Is it actually a date value stored in the field, or a date and time?

Let's say the database record has 1/1/2007 13:53:28 in the field. If you search for 1/1/2007 I would not expect it to match.

In such a case you might have to consider options such as...
  • Use a range, such as Between #m/d/y 00:00:00# and #m/d/y 23:59:59#.
  • Use a function (yes yes, I know what I said...) to look at just the date, without the time.
Of these two, obviously you'd expect the range to be more efficient, based on what I mentioned above.
Jan 7 '08 #7
debasisdas
8,127 Expert 4TB
Is this useful/effective to use datepicker for applications that are not allowed to use pointing devices?
You mean to say want to use only textbox and buttons and nothing else ?
Jan 7 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by David B | last post: by
3 posts views Thread by Dustin Wilson | last post: by
2 posts views Thread by Julie Wardlow | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.