473,396 Members | 1,992 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,396 software developers and data experts.

Filter on date in date field with default value Now()

Dear reader,

By a Date field with Now() as default value the content of the field is date
plus time.

As I need a filter in a query on date only (excluding time) I invented the
following solution:

Field in query DatePart: Format([DateNow];"yyyy") & "-"&

Format([DateNow];"mm")
& "-"&

Format([DateNow];"dd")

Criteria in query "2004-11-07"

It works but it looks to me as complicated to subtract the date part from
content of the date/time field for filtering.

Is there an easier way to use a date only filter in a date/time field?

Tanks for any help.

Kind regards,

Simon
Nov 13 '05 #1
4 5269
"S. van Beek" <S.v,Be**@HCCnet.nl> wrote in message
news:41*********************@reader20.nntp.hccnet. nl...
By a Date field with Now() as default value the content of the field is
date
plus time.


If you change default value to Date() the contend is date only.

Ciao
Bruno
Nov 13 '05 #2
Are you saying that your table has times, and you want to filter on date
only? Use the DateValue function on your field:

Field in query WhatDate: DateValue([DateNow])
Criteria in query #2004-11-07#

BTW, I wouldn't use DatePart as a name: there's a DatePart function in VBA,
so you run the risk of problems.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"S. van Beek" <S.v,Be**@HCCnet.nl> wrote in message
news:41*********************@reader20.nntp.hccnet. nl...
Dear reader,

By a Date field with Now() as default value the content of the field is date plus time.

As I need a filter in a query on date only (excluding time) I invented the
following solution:

Field in query DatePart: Format([DateNow];"yyyy") & "-"&

Format([DateNow];"mm")
& "-"&

Format([DateNow];"dd")

Criteria in query "2004-11-07"

It works but it looks to me as complicated to subtract the date part from
content of the date/time field for filtering.

Is there an easier way to use a date only filter in a date/time field?

Tanks for any help.

Kind regards,

Simon

Nov 13 '05 #3
Use Int(now()) is better than date() . Date causes problems.
"S. van Beek" <S.v,Be**@HCCnet.nl> wrote in message
news:41*********************@reader20.nntp.hccnet. nl...
Dear reader,

By a Date field with Now() as default value the content of the field is
date
plus time.

As I need a filter in a query on date only (excluding time) I invented the
following solution:

Field in query DatePart: Format([DateNow];"yyyy") & "-"&

Format([DateNow];"mm")
& "-"&

Format([DateNow];"dd")

Criteria in query "2004-11-07"

It works but it looks to me as complicated to subtract the date part from
content of the date/time field for filtering.

Is there an easier way to use a date only filter in a date/time field?

Tanks for any help.

Kind regards,

Simon

Nov 13 '05 #4
"S. van Beek" <S.v,Be**@HCCnet.nl> wrote in message
news:41*********************@reader20.nntp.hccnet. nl...
Dear reader,

By a Date field with Now() as default value the content of the field is
date
plus time.

As I need a filter in a query on date only (excluding time) I invented the
following solution:

Field in query DatePart: Format([DateNow];"yyyy") & "-"&

Format([DateNow];"mm")
& "-"&

Format([DateNow];"dd")

Don't use a calculated column in a where clause - it's better to modify your
criteria like so:

parameters [theDate] datetime;
select * from myTable
where
(
myDate >= [theDate]
and myDate < [theDate] +1
)

Nov 13 '05 #5

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

Similar topics

6
by: Jerome | last post by:
Hi, I know this is an old problem and I've already tried to look the solution up on the web but I didn't find what I need. So, there's the following situation: I've got an ASP page with a...
3
by: Nathan Bloomfield | last post by:
I am having difficulty filtering dates for a report. I have written the following code on a popup form which works with regular date fields , however, I am now trying to apply the same concept to...
3
by: Afton | last post by:
I would like to make a form that filters a report by Supervisor and by starting and ending date. I have the supervisors in a combo box, and that works. However, I do not know how to code to let...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
9
by: dee | last post by:
I'd like to filter by the following criteria: left(LeadDisposition,3) = "Sit" AND Appt_Date = Text767 I have no idea how to do this. Appreciate help.
2
by: sparks | last post by:
I am trying to set the default value on a forms field to the filter that I am passing to the form. The filter works fine but the field comes up blank. So I put in a default value and it works...
3
by: Finn Stampe Mikkelsen | last post by:
Hi I have defined a table in my database, with 2 date-fields. I have set a default value to DBNull. I have integrated a nullable datetimepicker control to my project and set the apropriate...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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,...

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.