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

Subtracting Dates

I have a (installation) date in a table that I put in manually. It is
the date we want to complete a job. In a form that uses data from that
table I want to add a text box that is bound to the installation date
but I want to subtract 7 days from the installation date. I tried
using [installation date] - 7 but that didn't work.

How can I have a text box display another's cells date - 7 days?

Thanks

Dec 8 '05 #1
8 10311
check out datediff in the help
-John

<If********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a (installation) date in a table that I put in manually. It is
the date we want to complete a job. In a form that uses data from that
table I want to add a text box that is bound to the installation date
but I want to subtract 7 days from the installation date. I tried
using [installation date] - 7 but that didn't work.

How can I have a text box display another's cells date - 7 days?

Thanks

Dec 8 '05 #2

<If********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a (installation) date in a table that I put in manually. It is
the date we want to complete a job. In a form that uses data from that
table I want to add a text box that is bound to the installation date
but I want to subtract 7 days from the installation date. I tried
using [installation date] - 7 but that didn't work.

How can I have a text box display another's cells date - 7 days?

Thanks


In addition to John's posting, also look at DateAdd in the help file. This
is better for adding or subtracting a number from a date than DateDiff.
DateDiff is better for comparing 2 dates.
Note: Look in the VBA help file for the 2 functions, not the Access help
file.

Jeff
Dec 8 '05 #3
Br
If********@gmail.com wrote:
I have a (installation) date in a table that I put in manually. It is
the date we want to complete a job. In a form that uses data from
that table I want to add a text box that is bound to the installation
date but I want to subtract 7 days from the installation date. I
tried using [installation date] - 7 but that didn't work.

How can I have a text box display another's cells date - 7 days?

Thanks

= DateDiff("d", -7, [InstallationDate])
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Dec 8 '05 #4
Oops, thanks Jeff. Yes dateAdd is what you want, not datediff.

"Jeff Smith" <No****@Not.This.Address> wrote in message
news:dn**********@lust.ihug.co.nz...

<If********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a (installation) date in a table that I put in manually. It is
the date we want to complete a job. In a form that uses data from that
table I want to add a text box that is bound to the installation date
but I want to subtract 7 days from the installation date. I tried
using [installation date] - 7 but that didn't work.

How can I have a text box display another's cells date - 7 days?

Thanks


In addition to John's posting, also look at DateAdd in the help file. This
is better for adding or subtracting a number from a date than DateDiff.
DateDiff is better for comparing 2 dates.
Note: Look in the VBA help file for the 2 functions, not the Access help
file.

Jeff

Dec 8 '05 #5
[installation date] - 7 should have worked, depending on how you entered it.
Did you place this in the Control Source of the textbox? Did you put an
equal sign in front of it? It is possible that the value is being treated as
text instead of as a date. Is the textbox that you enter the date into bound
to a field that is defined with a data type of Date/Time? I just tried your
entry to double check and it worked.

Does the control that has the date have the same name as the field it is
bound to? This will sometimes cause a problem when you try to refer to it,
Access doesn't know which to refer to, the control or the field, although it
usually doesn't matter if it would just pick one.

--
Wayne Morgan
MS Access MVP
<If********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
I have a (installation) date in a table that I put in manually. It is
the date we want to complete a job. In a form that uses data from that
table I want to add a text box that is bound to the installation date
but I want to subtract 7 days from the installation date. I tried
using [installation date] - 7 but that didn't work.

How can I have a text box display another's cells date - 7 days?

Thanks

Dec 8 '05 #6
Thanks for the help, Wayne I got your way to work I had forgotton to
put the = sign

But another question related to this.

I added this in a text box inside of a form. But the answer to the
equation =[installation date] - 7 does not appear in the actual table.
The reason that I want it to appear in the table is so I can make a
report with the information. On the contrary it seems at least when
using the wizard that I am not able to make a report off of a form.

So in summary. I want to be able to use equations to control what is
displayed in a column. But if I use a form and go to
properties/control source I seem to only be able to view that
information when I am looking at that paticular form, which means I
can't make a report out of that info.

I don't know if the last paragraph was a summary or just as confusing
but I would appreciate anyones help. thanks

Dec 19 '05 #7
Linds:

You can have a calculated field on a report the same way you have it on
your form. If it's always a calculated value, there is no real reason
to store it in a table since you can calculate it any time you need it.
If you need to parameterize your report based on the result of the
calculation, then build the expression into a query and base your
report on the query. For instance, you could type in something like
this in a blank column for your query:

CompletionDate: DateDiff("d", -7, [InstallationDate])

Then, you can put criteria to limit the records returned and you can
reference the field as CompletionDate in your report.

HTH,
Jana

Dec 19 '05 #8
Jana, thanks that definatly helps me out!

Dec 19 '05 #9

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

Similar topics

1
by: Jesse O | last post by:
I have two date fields, start_date and end_date. I'd like to subtract the two dates, and come up with a number (the number of difference between the two dates). What function is there to do...
2
by: Eddie | last post by:
When I subtract dates, I can't figure out what I get out. I first I thought it was in seconds, but that's not it. Then I figured maybe HHMMSS, but that does not seem to be it too. How can I...
6
by: Brian Henry | last post by:
How would i take two dates startdate and enddate and subtract startdate from enddate to figure the number of days between the two? thanks
9
by: Mike Fellows | last post by:
i have 2 dates one is todays date and the other is a future date i want to take todays date from ther future date and tell me how many days difference this is thanks in advance Mike...
3
by: Amjad | last post by:
I want to subtract two Date variables and show the result in this format: hh:mm:ss I'm thinking that there might be an easy way of doing that. something like: .... Return...
4
by: David S. Alexander | last post by:
How can I do simple subtraction in an XSLT. I want to read a few attribute values from an XML document, calculate their difference, and transform that value to an attribute in the XML output...
31
by: Spiro Trikaliotis | last post by:
Hello, I have a question regarding subtracting a pointer from another one. Assume I have two pointers p1 and p2, which both point to a memory area obtained with malloc(). Assume p1 = p2 + some...
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...
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
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
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,...
0
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...
0
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...

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.