473,666 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date problem: day/month getting switched on filter

7 New Member
Hi everyone,

I have a weird problem, and I cannot work out what's going on.

I have a continuous form (frmEnterCosts) based on a query (qryEnterCosts) . I have series of unbound combo boxes to filter various fields on this form, one of which (cboFilterPacki ngDate) filters the field 'PackingDate', which is a Date field.

There is a command button which takes the contents of each combo box to build the filter string and then applies the filter when it is pressed.

The piece of code within the OnClick event concerning the PackingDate is:

Expand|Select|Wrap|Line Numbers
  1. If Not Me.cboFilterPackingDate.ListIndex = -1 Then
  2.   strPackingDate = "[PackingDate] = #" & Me.cboFilterPackingDate & "#" & " AND"
  3. Else
  4.   strPackingDate = ""
  5. End If
My problem is that it doesn't seem to be handling the date correctly. If the date is something like 13/08/2010 (i.e. 13th August) which cannot be confused with another date (i.e. 8th of 13th Month doesn't exist), the filter works fine. If the selected date is, say, 05/07/2010 (5th July), it will filter for 07/05/2010 (7th May). And if the 'reverse' date does not exist in the data, it returns nothing.

I have put the filter string into a text box to see what's happening, and the filter string has the correct date (i.e. matches the combo box) it just filters the wrong date, and I cannot for the life of me figure out where its going wrong. There is nowhere in the database where the date is stored in the U.S format.

I've used Format in the code to try and force it, but I don't think this is the problem.

I would be grateful for any pointers as it's driving me a bit mad!

Thanks

Neil
Aug 28 '10 #1
3 6463
Neil Chinneck
7 New Member
Just to update:

If I open the form and filter on a date (16/09/2010) from the PackingDate field manually, then look at the filter, it looks like this:

((qryEnterCosts .PackingDate=#9/16/2010#))

So I could probably get around it by switching the day/month around in my code, but I do not see why it should be treating the date like this when it filters?

Thanks

Neil
Aug 28 '10 #2
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi Neil. The problem is that Access is actually interpreting date literals in the ANSI-standard way, which is indeed mm/dd/yyyy. It is switching the day and month where it is clear that the regional setting is applying, but leaving them where the regional setting can be interpreted as a valid mm/dd/yyyy date.

All is not lost, though, as all you need to do is to force the format of the date to the ANSI mm/dd/yyyy form and all should be well.

Replace line 2 above with:
Expand|Select|Wrap|Line Numbers
  1. strPackingDate = "[PackingDate] = " & Format(Me.cboFilterPackingDate, "\#mm/dd/yyyy\#") & " AND"
We have an Insights article on Literal date-times and their delimiters which explains why all this occurs.

-Stewart
Aug 28 '10 #3
Neil Chinneck
7 New Member
Thanks very much for the reply; it seems like an odd thing for Access to do, but I guess I'll have to live with it.

Thanks
Aug 30 '10 #4

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

Similar topics

5
3722
by: Dominique Javet | last post by:
Hello, I'm new to php and mysql and I use Dreamweaver MX 2004, so sorry for this "newbie" question... I've found no answer in the forum ... I've a date problem with my formular. In my mysql DB my filed "date" in table "experience" is like this: Y-m-d (2002-07-23). My fied`date` is date, NOT NULL with no default entry My form read well the date data depending the id, (pe. 30.02.2003), but when I submit a new date, I receive as result...
3
6295
by: Jas Shultz | last post by:
I'm using Win2K3 Enterprise edition with the latest .NET framework installed. I have this problem with getting "out of disk space" errors. It doesn't happen all the time but it does happen. When I installed Sharepoint Services I got the error and had to reboot and then everything was fine. I get it sometime when running aspx pages. It's very odd. Usually, I can just remove the application and readd it from the properties menu in the IIS...
2
2077
by: Danny | last post by:
Hi I'm using asp.net , visual studio.NET 2003 , c#. I have a problem that occurred only on my computer And not on other developer's computers. My CultureInfo.CurrentCulture is "he-IL" But when I'm using : DateTime.Now.ToShortDateString() (my short date format is dd/mm/yyyy) The function return every time a different date like "06/25/2004) even that the current date is "06/12/2004"
1
1268
by: David | last post by:
Hi, I have a problem in getting the status of the modem. Here is my code: HANDLE hfile; DCB dcb; hfile = CreateFile("BCM V.92 56K Modem", GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); i(hfile != INVALID_HANDLE_VALUE)
5
2291
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles DataGrid1.ItemCommand
0
1025
by: arlene5781 | last post by:
Hi Guys, please help.. Im having a problem in getting the Handle/Process ID in a existing application. Here's the existing code, i wonder how to get the &H4D7 and 1242. Do you have a tool for this? WriteLog("Looking for interest box...") text_interest.WaitConnectChildWindowId(window_params, "Edit", &H4D7, True, 600, 100) WriteLog("Click calculate button...") window_params.ButtonClickedPost(button_calculatepremium, 1242)
0
1572
by: sandeepk84 | last post by:
Hi all... I am facing a problem in getting attachments from Yahoo Classic using JavaMail. My program reads the attachments from gmail and Yahoo Beta. But attachments of type pdf or txt from classic Yahoo are having the problem. I use isMymeType function to check the type, can anyone say how the type should be checked for files from classic yahoo? ie. for gmail part.isMimeType("text/plain") or part.isMimeType("multipart/*") will work....
0
986
by: sejal17 | last post by:
Hello everyone, i have a problem with getting a print out of iframe in asp.net with language c#. an iframe contain a data from diffrent page(docoment1.htm). can any one help me in this problem. my code is as bellow. this code is in pageload of document2.aspx so when document2.aspx loaded it's print a data of document1.htm as in src of iframe
1
3160
by: naveenkongati | last post by:
Hi, How do we fetch only date and month from date column (Ex: 2008-11-10) in Mysql? Thanks
3
1937
by: vtpvp82 | last post by:
I am having problem in getting response from remote server for that I have written following script response got correctly but the data on the page is not displayed it gives “–“ in place of grid data. It’s because when actual page load in web browser it shows “-“ until loading is not completed after that it gives actual value after successful completion of loading of the page. Script I have written is as follows : <%...
0
8443
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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...
0
7385
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5663
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
4198
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...
0
4366
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.