Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math problem 1

Status
Not open for further replies.

jono261970

Programmer
Jun 28, 2002
182
GB
Hi,

I was hoping somebody could help me convert the following in to code:

I have two fields in access that I want to manipulate:


"date purchased" field in date format, for example 09/02/2001

"warranty" field in number format, for example 3

So, I am thinking if I add 3 years to the date purchased and then subtract from the current date I should have a rough idea of how much warranty is left. This is no doubt easier said than done.


I am using VB 6 and the DAO method.

Thanks in advance.

jono

A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
 
Try this.
___
[tt]
Dim Dt As Date, DaysLeft As Long
'Date of purchase
Dt = #9/2/2001# 'September 2, 2001
'Add warrenty period (3 yrs.)
Dt = DateAdd("yyyy", 3, Dt)
'Number of days left from current date.
DaysLeft = Dt - Date

MsgBox DaysLeft
[/tt]
 
Hi Hypetia,

your code was spot on. Thanks very much.

jono


A good fortune may forbode a bad luck, which may in turn disguise a good fortune.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top