473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Simple query question on Date/Time

255 100+
I'm fixing a query that takes date filter on specific date (e.g. 10/13/2010). The date field in the table source also contains time along with the date. (E.g. 13/10/2010 6:26:45 AM)

On the where clause of the query, how can I filter the date with the standard short date format? I tried 2 of the followings but didn't work.
Expand|Select|Wrap|Line Numbers
  1. Method 1: WHERE Date = #10/13/2010#
  2. Method 2: WHERE Date BETWEEN #10/13/2010# AND #10/13/2010#
Oct 15 '10 #1

✓ answered by NeoPa

I think you're looking for DateValue() :
Expand|Select|Wrap|Line Numbers
  1. WHERE (DateValue(Date) = #10/13/2010#)

7 1906
colintis
255 100+
Just used a longer method to solve this matter, I would appreciate to find a solution that is shorter than this.
Expand|Select|Wrap|Line Numbers
  1. WHERE Date BETWEEN #10/13/2010 00:00:00# AND #10/13/2010 23:59:59#
Oct 15 '10 #2
MMcCarthy
14,534 Expert Mod 8TB
Simple answer is ... if you don't specify a time then Access assumes a time of 00:00 so when you say between 10/13/2010 and 10/13/2010 it assumes you mean between 10/13/2010 00:00 and 10/13/2010 00:00 so you get no results. The only two options are either to do what you are doing and give the times or to set the second date to be the day after. In other words to say between 10/13/2010 and 10/14/2010 which since it assumes a time of 00:00 for both dates will only return for the 10/13/2010.

Hope that makes sense :)

Mary
Oct 15 '10 #3
colintis
255 100+
Yep, that makes sense to me, but would be it possible that the time at 10/14/2010 00:00:00 also included in the between result? I know that the chance of getting exactly that time is nearly impossible, but still curious to know. :P
Oct 15 '10 #4
MMcCarthy
14,534 Expert Mod 8TB
I don't think so but you would have to test it to be sure. Set up a dummy record with that date and time and see if it shows up in the results.
Oct 15 '10 #5
NeoPa
32,556 Expert Mod 16PB
I think you're looking for DateValue() :
Expand|Select|Wrap|Line Numbers
  1. WHERE (DateValue(Date) = #10/13/2010#)
Oct 15 '10 #6
colintis
255 100+
Beautiful NeoPa, thank you :D
Oct 19 '10 #7
NeoPa
32,556 Expert Mod 16PB
Always a pleasure mate :-)
Oct 19 '10 #8

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

Similar topics

1
by: Thomas Bartkus | last post by:
If we have a date/time field and are doing frequent queries WHERE {date/time field} BETWEEN TimeA AND TimeB Does it make sense, query speed wise, to create an index on the date/time field? ...
1
by: compusup3000 | last post by:
Hi, I have an orders database and I need to be able to write a query that groups sales by: 1. Date 2. Time of day (both am and pm) I currently have a date/time field named "Submitted" that...
5
by: Javier | last post by:
I have a field type Date/Time that automatically defaults to Now(). I'm having a problem writing a query that will retrieve all the records for a specific date the user to enters when prompted. I...
0
by: 321ConTact | last post by:
I am having a bad day for thought, and I can't remember how to create a function that will return a date/time. I have a query with a date field in "mm/dd/yyyy hh:nn:ss am/pm" format. If I enter...
3
by: Don Sealer | last post by:
I'm guessing this is pretty simple however not simple enough for me. I'm developing a database to track expenses, income, banking transactions, etc. I have a very simple query with four fields,...
2
by: Rolf | last post by:
Hi all, I Have a web page wich displays some data from an access DB using the Datalist control. I have 1 problem with a field of the type Data/Time. When I display the field using <%#...
11
by: Dixie | last post by:
How can I programatically, take some Date/Time fields present in a table in the current database and change their type to text? dixie
7
by: Jerome | last post by:
Hallo, I know a lot has already been told about date/time fields in a database but still confuses me, specif when dealing with SQLserver(Express). It seems that sqlserver only accepts the date in...
5
by: devagupt | last post by:
I have a question . I have a Chart which i run from a query. The chart has 3 fields Line , Date , Time in mins. The purpose of the chart is to display the sum of all the "time in mins" in a...
1
by: IamMacro | last post by:
hulp5 = "02-02-2006" timesynced = Date.Parse(hulp5) Dim msqlDA As New MySqlDataAdapter("select * from Work where DateCreated <' " & timesynced & " ' ", myconnection) I cant seem to get the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
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,...
0
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
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,...
0
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...
0
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
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...

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.