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

Subtract Two Years From Current Date

68
Hi everybody,

I want to create a code that subtract two years from the current date and returns the data.

For instance

Current date= 05/05/2009
Date before two years=current date-(2 years)
Date before two years=MM/DD/YYYY

Appreciate your cooperation
May 5 '09 #1
3 11194
JustJim
407 Expert 256MB
@ahd2008
Hi,

The function you want is DateAdd

Expand|Select|Wrap|Line Numbers
  1. dtPrevious = DateAdd("yyyy", -2, dtCurrent)
Please read the help file for DateAdd for further usage of the Interval argument ("yyyy" in this example).

Jim
May 5 '09 #2
ahd2008
68
thanks a lot bro and thx for the advice too
May 5 '09 #3
JustJim
407 Expert 256MB
No problem, glad to be of assistance.

Jim
May 5 '09 #4

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

Similar topics

8
by: dlx_son | last post by:
Here is the code so far <form name="thisform"> <h3>Enter time to add to or subtract from:</h3> (If not entered, current time will be used)<br> Day: <input name="d1" alt="Day of month"...
2
by: Dennis Kuhn | last post by:
I have a timecard logging program in Access97 that I've used for a few years now. Most of the year it works without problems. But... Every January, when logging in the December cards, the data...
7
by: Jimbo | last post by:
Anyone know how I can subtract 12 months from the current date?
3
by: Arne Gemsa | last post by:
Hi, I want to get a starttime. To get this I have to subtract the runtime from a unit e.g. 08:40:15 from a date e.g. 2007-03-29 16:48:30. So the starttime is 2007-03-29 08:08:15. Is there any...
10
by: dan | last post by:
Am i breaking any rules when I loop dates like // Determine Memorial Day intFlag = 0; memDayHol = new Date (currentYear, 4, 31); while (intFlag == 0) { if (memDayHol.getDay() == 1) {intFlag...
2
by: KA NMC | last post by:
I need help with the syntax below to subtract two years from the current date select oe_hdr.customer_id from oe_hdr where year (oe_hdr.order_date) >= year (getdate()-2 ) Thanks
6
by: lptl | last post by:
I know the title is misleading. I am working on a class project where we are trying to setup a notification system written in PHP and using an MySQL database. We are trying to set-up a notification...
3
by: mfsiddiq | last post by:
HI i wish to know how i can subtract one month from the current date in actionscript
1
by: Vikas Jain | last post by:
hi, please tell me how to subtract month from current date. Thanks in advance. Vikas Jain
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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,...

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.