473,508 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

filtering dates

14 New Member
how can i filter dates in vb6 and msaccess 2000.. im using adodc my code is

pickfrom and pickto are datetime picker controls..
dtr is my table

Adodc3.CommandType = adCmdText
Adodc3.RecordSource = "select * from dtr where dtr.[employee number]='" & Label4.Caption & "' and dtr.date between " & pickfrom.Value & " and " & pickto.Value & " order by dtr.date"
Adodc3.Recordset.Requery
Adodc3.Refresh

but the results are not correct..
i also tried to used the logical operators rather than BETWEEN..

the data types are date/time..
Dec 11 '06 #1
6 1876
Peter Timbol
14 New Member
got it guys you must include the # symbol... hope it helps you too..
Dec 11 '06 #2
aaryan
82 New Member
got it guys you must include the # symbol... hope it helps you too..
hi peter,
cd u just write the full code for me as i am also caught with the same.
Dec 11 '06 #3
Killer42
8,435 Recognized Expert Expert
It would be something along these lines...
Expand|Select|Wrap|Line Numbers
  1. Adodc3.CommandType = adCmdText
  2. Adodc3.RecordSource = _
  3.   "select * from dtr where dtr.[employee number]='" _
  4.   & Label4.Caption & "' and dtr.date between #" _
  5.   & Format(pickfrom.Value, "mm/dd/yyyy") _
  6.   & "# and #" & Format(pickto.Value, "mm/dd/yyyy") _
  7.   & "# order by dtr.date"
  8. Adodc3.Recordset.Requery
  9. Adodc3.Refresh
(I've just chopped up the long line for readability in the Code box here).

It's important to remember that when you insert date literals into SQL using the # delimiters, you must put the date in American (m/d/y) format. Some databases such as Access might try to interpret other formats, but it can cause confusion, especially since in certain cases they might get it right only for days after the 12th of the month.

See NeoPa's "sticky" threads at the top of the Access forum for more info.
Dec 11 '06 #4
Peter Timbol
14 New Member
hi peter,
cd u just write the full code for me as i am also caught with the same.

Adodc3.CommandType = adCmdText
Adodc3.RecordSource = "select * from dtr where dtr.[employee number]='" & Label4.Caption & "' and dtr.date between #" & pickfrom.Value & "# and #" & pickto.Value & "# order by dtr.date"
Adodc3.Recordset.Requery
Adodc3.Refresh

or you can include FORMAT given by Killer42,

be sure you have DATE/TIME data type in your database and the DATAFORMAT of your datetime picker control is the same as the DATA FORMAT in your database, if you don't want to include the FORMAT.
Dec 12 '06 #5
aaryan
82 New Member
Adodc3.CommandType = adCmdText
Adodc3.RecordSource = "select * from dtr where dtr.[employee number]='" & Label4.Caption & "' and dtr.date between #" & pickfrom.Value & "# and #" & pickto.Value & "# order by dtr.date"
Adodc3.Recordset.Requery
Adodc3.Refresh

or you can include FORMAT given by Killer42,

be sure you have DATE/TIME data type in your database and the DATAFORMAT of your datetime picker control is the same as the DATA FORMAT in your database, if you don't want to include the FORMAT.
thank u all guys, i got it
Dec 14 '06 #6
Good Job Thanks guys!
Oct 6 '10 #7

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

Similar topics

7
2636
by: Nathan Bloomfield | last post by:
Hi All, I am hoping someone out there will be kind enough to find out where my code is going wrong. The current code is inefficiant but hopefully it will convey the data I require to be...
1
2461
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
8
6389
by: Ragbrai | last post by:
Howdy All, I have a query that is used for filtering results to be used in a combo box. The query needs to test fields from both a table and then unbound text boxes on the form that also contains...
3
1860
by: iamguyster | last post by:
Hi, I have an exercise I need to give to my pupils (I'm a teacher!) and I am trying to get a query working preferably using the query design view, without having to edit the SQL. The query involves...
9
2370
by: Anneybo | last post by:
Alright, I give up! I'm asking the experts. I have created a database that calculates PTO for employees. I need to be able to cache the report by user entered dates and specific employee names. I...
18
2496
by: mlcampeau | last post by:
I have a lengthy query that I am now trying to filter. The query calculates an employee's Anniversary Date in which they are eligible for the next level of Annual Vacation. (i.e. For 1-6 years of...
2
2577
by: ccwells | last post by:
Hi, I am a novice to VB, using Access 2003 on a XP-SP2 platform, and I have a small database for tracking expenses, and want to be able to filter my expense report by date. I currently have a...
2
1561
by: Big X | last post by:
Hi, I am having a little trouble with some data I have been sent. Seems they want me to remove all the date that have a 5 year expiry date. I receive the data in csv file so the properties of the...
2
1537
by: poteatc | last post by:
I want to filter my reports according date and time. I am already successful with filtering dates and times, but not overnight. I want to filter according to a shift that starts for example,...
3
1587
by: zandiT | last post by:
Hello I have an access report and im using a query to filter the report using Date parameters eg Start Date-12 May 2009 and End Date-30 September 2009. the query works perfectly. My problem is...
0
7118
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4706
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
415
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.