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

add two years to date string

daJunkCollector
Hey,

I have a string variable, $s_dateboxEffectiveStartDate

I need to add - two years minus one day - to this variable. Could anyone offer any advise?


Expand|Select|Wrap|Line Numbers
  1. function UpdateShipAndDeliverDates(ElementName) {
  2.         if(ElementName=='s_dateboxEffectiveStartDate') {
  3.             document.MyForm.s_dateboxEffectiveEndDate.value=(document.MyForm.s_dateboxEffectiveStartDate.value) + (TWO YEARS MINUS ONE DAY);
  4.         } else if(ElementName=='s_dateboxEffectiveEndDate') {
  5.             document.MyForm.s_dateboxEffectiveStartDate.value=(document.MyForm.s_dateboxEffectiveEndDate.value) - (TWO YEARS MINUS ONE DAY);
  6.         }
  7.     }
Jun 17 '08 #1
5 2374
r035198x
13,262 8TB
Looks like you want to do that using Javascript?
Have a look at the Date functions reference and try it.
Jun 18 '08 #2
Hrm...looks good. Thanks man.
Jun 18 '08 #3
Hey,

I have a string variable, $s_dateboxEffectiveStartDate

I need to add - two years minus one day - to this variable. Could anyone offer any advise?

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.     function UpdateShipAndDeliverDates(ElementName) {
  3.         if(ElementName=='s_dateboxEffectiveStartDate') {
  4.             document.MyForm.s_dateboxEffectiveEndDate.value=(document.MyForm.s_dateboxEffectiveStartDate.value);
  5.         } else if(ElementName=='s_dateboxEffectiveEndDate') {
  6.             document.MyForm.s_dateboxEffectiveStartDate.value=(document.MyForm.s_dateboxEffectiveEndDate.value);
  7.         }
  8.     }
  9. </script>
  10.  
  11.  
  12.  
Jun 18 '08 #4
r035198x
13,262 8TB
Have you tried to use any of the functions suggested here yet?
Jun 19 '08 #5
acoder
16,027 Expert Mod 8TB
The Date object is pretty dynamic and very easy to add years/months/days to it. Create a Date object and use the set*** functions to add by adding to the get*** versions.

ps. I've moved and merged these threads.
Jun 19 '08 #6

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

Similar topics

7
by: Bambero | last post by:
Hello all Problem like in subject. There is no problem when I want to count days between two dates. Problem is when I want to count years becouse of leap years. For ex. between 2002-11-19...
6
by: carl.barrett | last post by:
Hi, I have a continuous form based on a query ( I will also be creating a report based on the same query). There are 2 fields: Date Obtained and Date Of Expiry I want a further 3 columns...
5
by: Juan | last post by:
Hi everyone, is there a function that calculates the exact amount of Years, Months, and Days between two days? TimeDiff is not good enough, since it calculates, for example: Date 1: Dec....
14
by: jpr | last post by:
Friends, I have a form with four fields, date1, date2, date3 and date4. All these have all a mm/dd/yyyy format and have their source to a table. I need to add an unbound control (I will name...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
23
by: thebjorn | last post by:
For the purpose of finding someone's age I was looking for a way to find how the difference in years between two dates, so I could do something like: age = (date.today() - born).year but that...
2
by: ichew | last post by:
I have two dates - Date Joined and Actual Last Day. How do I find the YIS in for format of Years and Month from these two dates. Eg, Date Joined: 28/06/1971 and Actual Last Day: 24/01/2007, then...
0
by: sharsy | last post by:
Hi, I've setup a query that compares the difference (in years) between two date fields (Joining Date & Date Cancelled) and then totals how many people fit into each category (0 years, 1 year, 2...
3
by: ahd2008 | last post by:
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)...
8
by: Constantine AI | last post by:
Hi i have generated some code that takes the combination of the current year and next year followed by triming and storing this value as AcademicID. I then want the code to check whether the...
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...
1
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
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.