473,830 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date search problem

Hi
I have a excel worksheet that contains a lot of data one on the columns
is the date(formatted as short date "dd/mm/yyyy)

i import this worksheet into access as a table the date field is
formatted as short date
problem is i cant query the dates, when i do it returns all the
records.
can anyone tell me how to query these dates correctly please

thanks
kevin

Nov 13 '05 #1
8 1836
When you imported the Excel data, what kind of field did you end up with?
Open your Access table in design view, and check the Data Type of the field.

If you have a Date/Time field, you should be able to query it successfully.
For specifics, see:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html

If you ended up with some other kind of field, you will need to convert to a
date in order to get the right results, as string comparisons will be
unreliable. DateSerial(), Left(), Mid(), Right(), and CVDate() might help.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kevcar40" <ke******@btint ernet.com> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.com.. .

I have a excel worksheet that contains a lot of data one on the columns
is the date(formatted as short date "dd/mm/yyyy)

i import this worksheet into access as a table the date field is
formatted as short date
problem is i cant query the dates, when i do it returns all the
records.
can anyone tell me how to query these dates correctly please

Nov 13 '05 #2

Allen Browne wrote:
If you have a Date/Time field, you should be able to query it successfully.
For specifics, see:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html


Canada is a member of the Commonwealth of Nations. Many Canadians use
mm/dd/yy. Few use dd/mm/yy.
Because Canada has adopted SI, the International System of Units, ISO
8601, is the basis for its "official" representation of Dates and Times
(Canada Standards Council has its own $35.00 manifestation of this).
ISO 8601 presents YYYY-MM-DD as the appropriate simple representation
of dates. YYYY-MM-DD has two strengths; it is easily sorted and it is
not so easily confused.
To the best of my knowledge, Access, VBA, JET, JET SQL and MS-SQL
always interpret YYYY-MM-DD correctly.
I recommend to everyone that he/she use YYYY-MM-DD everywhere.

Nov 13 '05 #3
Bear in mind that the Jet Sql does not interpret dates as dd/mm/yy.
AFAIK (open to correction) the dates should be in American Date Format
mm/dd/yy.
Alternatively, you'd require a function to change dd/mm/yy format into
mm/dd/yy format.

osmethod

Nov 13 '05 #4
Try this code in a modern version of Access:

CurrentProject. Connection.Exec ute "CREATE PROCEDURE QueryDate AS SELECT
* from Transactions WHERE fldDate < #2002-06-01#"
Debug.Print DBEngine(0)(0). QueryDefs("Quer ydate").SQL
End Sub

Nov 13 '05 #5
Thanks, Lyle.

I agree that the ISO standard yyyy-mm-dd is a) a standard, and b) the most
logical date format. IME also, JET always interprets it correctlly, so I am
not aware of any problems with using that approach.

However, I don't believe that is the standard Access/JET format for literal
dates. Just as VBA spins the date around to mm/dd/yyyy format, so any
literal date you type into the query interface in Access is converted to
mm/dd/yyyy format in the SQL statement.

It is therefore my recommendation that users and developers format literal
dates in SQL statements in the same way that Microsoft does.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"lylefair" <ly***********@ aim.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .

Allen Browne wrote:
If you have a Date/Time field, you should be able to query it
successfully.
For specifics, see:
International Date Formats in Access
at:
http://allenbrowne.com/ser-36.html


Canada is a member of the Commonwealth of Nations. Many Canadians use
mm/dd/yy. Few use dd/mm/yy.
Because Canada has adopted SI, the International System of Units, ISO
8601, is the basis for its "official" representation of Dates and Times
(Canada Standards Council has its own $35.00 manifestation of this).
ISO 8601 presents YYYY-MM-DD as the appropriate simple representation
of dates. YYYY-MM-DD has two strengths; it is easily sorted and it is
not so easily confused.
To the best of my knowledge, Access, VBA, JET, JET SQL and MS-SQL
always interpret YYYY-MM-DD correctly.
I recommend to everyone that he/she use YYYY-MM-DD everywhere.

Nov 14 '05 #6
thanks all
i will try your suggestions and get back if any further problems
thanks again

Nov 14 '05 #7
Ok tried a few things but getting nowhere
my date field is formatted as short date(in both access and excel)
here is the code
i have 2 text boxes called txtStartDate and txtEndDate
these boxes hold the result of dates selected from a pop upcalender
this code returns all the dates
strSQL = "SELECT
All_Areas_Resul t.Identified_Re pair,All_Areas_ Result.Area,sum (All_Areas_Resu lt.Quantity)
as Quantity " & _
"FROM All_Areas_Resul t " & _
"WHERE All_Areas_Resul t.Dates Between" &
SQLDate(Me.txtS tartDate.Value) & "and " & SQLDate(Me.txtE ndDate.Value)
& _
"GROUP BY All_Areas_Resul t.Identified_Re pair,
All_Areas_Resul t.Area"
qdf.SQL = strSQL
DoCmd.OpenQuery "All_Areas_Resu lt_dated", acViewNormal

i have also tried
this code crashes

strSQL = "SELECT All_Areas_Resul t.Identified_Re pair,
All_Areas_Resul t.Area, sum(All_Areas_R esult.Quantity) as Quantity " & _
"FROM All_Areas_Resul t " & _
"WHERE All_Areas_Resul t.Dates Between # &
Me.txtStartDate .Value # and # Me.txtEndDate.V alue # & _
"and [Area] <> 'Head'" & _
"and [Area] <> 'Hot Test'" & _
"GROUP BY All_Areas_Resul t.Identified_Re pair,
All_Areas_Resul t.Area"
qdf.SQL = strSQL
DoCmd.OpenQuery "All_Areas_Resu lt_dated", acViewNormal
any suggestions?
thanks

kevin

Nov 14 '05 #8
If you open table All_Areas_Resul t in design view, what data type is your
Dates field? (Sometimes after import you end up with another type such as
Text.)

What result are you getting? An error message? A query with no records?
Access shut down by Windows? other?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"kevcar40" <ke******@btint ernet.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Ok tried a few things but getting nowhere
my date field is formatted as short date(in both access and excel)
here is the code
i have 2 text boxes called txtStartDate and txtEndDate
these boxes hold the result of dates selected from a pop upcalender
this code returns all the dates
strSQL = "SELECT
All_Areas_Resul t.Identified_Re pair,All_Areas_ Result.Area,sum (All_Areas_Resu lt.Quantity)
as Quantity " & _
"FROM All_Areas_Resul t " & _
"WHERE All_Areas_Resul t.Dates Between" &
SQLDate(Me.txtS tartDate.Value) & "and " & SQLDate(Me.txtE ndDate.Value)
& _
"GROUP BY All_Areas_Resul t.Identified_Re pair,
All_Areas_Resul t.Area"
qdf.SQL = strSQL
DoCmd.OpenQuery "All_Areas_Resu lt_dated", acViewNormal

i have also tried
this code crashes

strSQL = "SELECT All_Areas_Resul t.Identified_Re pair,
All_Areas_Resul t.Area, sum(All_Areas_R esult.Quantity) as Quantity " & _
"FROM All_Areas_Resul t " & _
"WHERE All_Areas_Resul t.Dates Between # &
Me.txtStartDate .Value # and # Me.txtEndDate.V alue # & _
"and [Area] <> 'Head'" & _
"and [Area] <> 'Hot Test'" & _
"GROUP BY All_Areas_Resul t.Identified_Re pair,
All_Areas_Resul t.Area"
qdf.SQL = strSQL
DoCmd.OpenQuery "All_Areas_Resu lt_dated", acViewNormal
any suggestions?
thanks

kevin

Nov 14 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2288
by: Greg | last post by:
I have a page that searches a database by a repairman's name and by a date range. It pulls info by the repairman's name but pulls all info in the database regardless of the date. Below is the code of the two pages. What am I missing? This page calls the script datersearch.php ************ searchrdates.php ************
2
1372
by: Alistair | last post by:
this is really bugging me as I can't see why this is happening. I have a page which runs as the reult of a search, records details of the search, it goes a bit like this. get dearch criteria and search datebase. if no data is found then create a record for that search, including the search query, the search count (set to 1), and the search date.
1
1227
by: bafidi | last post by:
i have a table: RECORDS1 fields: DATE1,NAME1 data is 21,10,2005 10:24:34 ANDY 21,10,2005 15:24:45 DAVID i search date with this sql
6
2771
by: kevin carter | last post by:
hi i have a table conataining several fields one of which is date i want to be able to search the table on the date field using code. the code below generates the query from a form, however i get an error message "Run time Error 2001" when this code is run. Can anyone please tell me where i have gone wrong or how to stop this error message Dim db As DAO.Database Dim qdf As DAO.QueryDef
13
2438
by: alive84 | last post by:
Hi there, I have a two problems concerning option button values on a report and data report creator reports. The situation: I have three option value boxes two have 3 option and one has only two option buttons. They have values 1, 2, 3. Everything is standard. Now when I create the report, I have only the number for each record on the report, which is kind of ugly and not user-friendly. Is there a chance to turn this values into actual...
0
1471
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I've migrated from Win 2003 server to Win 2008 server. I've been banging my head agaist a wall for several days now trying to figure this out. I have the following script that will search the file system and return file names of all files within a folder and subfolders that meet the search criteria of DateLastModified. To test the output, you can use the following link:
0
9793
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
10777
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...
1
10526
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,...
0
10206
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5617
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
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4416
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
3960
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
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.