473,666 Members | 2,278 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.CommandT ype = adCmdText
Adodc3.RecordSo urce = "select * from dtr where dtr.[employee number]='" & Label4.Caption & "' and dtr.date between " & pickfrom.Value & " and " & pickto.Value & " order by dtr.date"
Adodc3.Recordse t.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 1891
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.CommandT ype = adCmdText
Adodc3.RecordSo urce = "select * from dtr where dtr.[employee number]='" & Label4.Caption & "' and dtr.date between #" & pickfrom.Value & "# and #" & pickto.Value & "# order by dtr.date"
Adodc3.Recordse t.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.CommandT ype = adCmdText
Adodc3.RecordSo urce = "select * from dtr where dtr.[employee number]='" & Label4.Caption & "' and dtr.date between #" & pickfrom.Value & "# and #" & pickto.Value & "# order by dtr.date"
Adodc3.Recordse t.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
2646
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 filtered. Basically I have a popup form which has 6 optional controls to filter records in another form. The code below does not work. Can anyone suggest some correctons or alternatives.
1
2471
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. Function DateCalc (blah...) As Variant Do Stuff... If Not IsNull(varNewDate) Then DateCalc = varNewDate End If End Function
8
6400
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 the combo box. The fields I am working with are date fields that are formated as Short Date. I have written an IIF statement and placed it within the Criteria section of the Date field that I am trying to filter by. The current IIF statement works...
3
1867
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 three tables; Admission, Ward & Patient. The query is to initially return a list of all the wards with the total number of patients on each one. This is fine, using the following SQL: SELECT Wards.Name, Wards., Count(Patients.) AS FROM Wards...
9
2379
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 have been able to get the dates to work with the following VBA script: .. Private Sub cmdOK_Click() Dim strReport As String 'Name of report to open. Dim strField As String 'Name of your date field. Dim strWhere As String ...
18
2530
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 service, you qualify for 15 days vacation, etc.) I am trying to filter the report to show only those names whose anniversary date falls into the following year. Employees are entitled to their vacation Jan.1 of their upcoming anniversary date. (i.e.,...
2
2585
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 form with two list boxes, purchase and payment type, and then two date fields txtStartDate and txtEndDate. Filter works fine when no dates are chosen, problem is with my date picker - if I choose dates I get a "syntax error (missing operator)" error in...
2
1568
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 fields I can set in access to text or date which ever is needed. Atm I ran a sql query not like "*2013" which give me every thing before that year. I was wondering in the criteria box in access in expiry date field how to do this. I would like to be...
2
1546
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, 10/19/2008 Date From 10/20/2008 Date To 17:00 Start Time 7:00 End Time (How do I get all of the results in between ?) The results...
3
1594
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 recently i formated the date values so they appear as May 2009 instead of 12 May 2009. When i tried to use the filtering query again it did not work. Instead the result set from the query only showed records from the two dates in the parameter, ...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8550
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6191
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5662
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2769
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 we have to send another system
2
2006
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1769
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.