473,387 Members | 1,621 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,387 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 2373
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
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: 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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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.