Hi,
Using Java script I am trying to create code where when you place in
the start date it automatically calculates 6 months for the
experations date. For example when I place 01/01/04 as the issue date
the experation date should automaically generate as 06/01/04. I would
appreciate it if anyone could help me.
Thank you
Sandy 16 41604
I have read the following message from sa**********@ya hoo.com (sandy)
and have decided to lend my vast knowledge.
The writer said: Hi, Using Java script I am trying to create code where when you place in the start date it automatically calculates 6 months for the experations date. For example when I place 01/01/04 as the issue date the experation date should automaically generate as 06/01/04. I would appreciate it if anyone could help me.
Thank you Sandy
and my reply is:
The following must be considered before an answer can be given. What if
the date is the 31st and there is no 31st six months later?
What is six months after 03/31/04?
BTW: Six months after 01/01/04 is 07/01/04 not 06/01/04.
--
Dennis M. Marks http://www.dcs-chico.com/~denmarks/
Replace domain.invalid with dcsi.net
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Here is a simple script that may get you started.
var date = new Date();
var date6MonthsFrom Now = new Date(date.getTi me() + (182*24*60*60*1 000));
the formula is simply [current time in mils + (#days in 6 months * #hrs in
day * #mins in hrs * #sec in min * #mils in sec)]
Regards
Mike
Mike <mi************ *****@synovic.c om> wrote: Here is a simple script that may get you started.
var date = new Date(); var date6MonthsFrom Now = new Date(date.getTi me() + (182*24*60*60*1 000));
the formula is simply [current time in mils + (#days in 6 months * #hrs in day * #mins in hrs * #sec in min * #mils in sec)]
How many days are in 6 months depends directly on what 6 month span you
cover.
Of the 12 6 month spans that can be covered, only 2 have 182 days:
Jan-Jun 181 days
Feb-July 181 days
Mar-Aug 184 days
Apr-Sep 183 days
May-Oct 184 days
Jun-Nov 183 days
July-Dec 184 days
Aug-Jan 184 days
Sep-Feb 181 days
Oct-Mar 182 days
Nov-Apr 181 days
Dec-May 182 days
Means that your script is only right 1/6 (or ~17% of the time), not what
I would consider very efficient.
And that does not take into account leap day every 4 years, which is a
problem of its own and introduces 6 more possibilities:
Feb-July 182 days
Mar-Aug 185 days
Apr-Sep 184 days
May-Oct 185 days
Jun-Nov 184 days
July-Dec 185 days
Aug-Jan 185 days
but your correctness ratio is still 1/6.
--
Randy
"Dennis M. Marks" <de******@domai n.invalid> wrote in message
news:1201200415 43585567%de**** **@domain.inval id... I have read the following message from sa**********@ya hoo.com (sandy) and have decided to lend my vast knowledge.
BTW: Six months after 01/01/04 is 07/01/04 not 06/01/04.
Over here six months after 01/01/04 is 01/07/04 :-)
Cheers
Richard.
Try this:
Date.prototype. addMonths = function(n)
{
this.setMonth(t his.getMonth()+ n);
return this;
}
var d = new Date().addMonth s(6);
Regards,
Willie
Try this:
Date.prototype. addMonths = function(n)
{
this.setMonth(t his.getMonth()+ n);
return this;
}
var d = new Date().addMonth s(6);
Regards,
Willie
not tested... but I dont think that will work
say the date is 31st March 2004
if you add 6 months to that you would end up with 31st September
2004... Which is a problem because there isn't 31 days in September.
The best way is to always calculate in days...
6 months = 26 weeks (52/2)
26 weeks *7 = 182
So your best always adding 182 to the date.
HTH
Al.
On 12 Jan 2004 23:22:38 -0800, wi****@brainjac ked.com (Willie Lau)
wrote: Try this:
Date.prototype .addMonths = function(n) { this.setMonth(t his.getMonth()+ n); return this; }
var d = new Date().addMonth s(6); Regards, Willie
I'd have to disagree with this and agree with mikes
they are 52 weeks in a year. or 12 months.
so 6 months is 26 weeks and a quarter is 13 weeks
they are 7 days a week
so 6 months = 26 * 7 = 182 days
or a quarter = 13 * 7 = 91 days
If you want to add just a month then that is the difficult one to do
as there isn't any set number of week so to work that out we go.
13 weeks / 3 = 4.3333333 weeks per month.
4.3333333 * 7 = 30.3333333 DAYS per month
so if you want to add one month you need to add the following number
of milliseconds to the date:
1000 * 60 * 60 * 24 * 30.33333333 = 2620800000
var date1MonthsFrom Now = new Date(date.getTi me() +
parseInt(30.333 3333*24*60*60*1 000)); var date6MonthsFrom Now = new Date(date.getTi me() + (182*24*60*60*1 000));
so by adding 182 days, like mike has done here is the correct way to
add "6 months"
Al.
On Mon, 12 Jan 2004 21:33:07 -0500, Randy Webb
<hi************ @aol.com> wrote:
Mike <mi************ *****@synovic.c om> wrote:
Here is a simple script that may get you started.
var date = new Date(); var date6MonthsFrom Now = new Date(date.getTi me() + (182*24*60*60*1 000));
the formula is simply [current time in mils + (#days in 6 months * #hrs in day * #mins in hrs * #sec in min * #mils in sec)]
How many days are in 6 months depends directly on what 6 month span you cover.
Of the 12 6 month spans that can be covered, only 2 have 182 days:
Jan-Jun 181 days Feb-July 181 days Mar-Aug 184 days Apr-Sep 183 days May-Oct 184 days Jun-Nov 183 days July-Dec 184 days Aug-Jan 184 days Sep-Feb 181 days Oct-Mar 182 days Nov-Apr 181 days Dec-May 182 days
Means that your script is only right 1/6 (or ~17% of the time), not what I would consider very efficient.
And that does not take into account leap day every 4 years, which is a problem of its own and introduces 6 more possibilities:
Feb-July 182 days Mar-Aug 185 days Apr-Sep 184 days May-Oct 185 days Jun-Nov 184 days July-Dec 185 days Aug-Jan 185 days
but your correctness ratio is still 1/6.
Harag wrote: I'd have to disagree with this and agree with mikes
they are 52 weeks in a year. or 12 months.
so 6 months is 26 weeks and a quarter is 13 weeks
That depends directly on your definition of a month.
they are 7 days a week
so 6 months = 26 * 7 = 182 days or a quarter = 13 * 7 = 91 days
If you want to add just a month then that is the difficult one to do as there isn't any set number of week so to work that out we go.
13 weeks / 3 = 4.3333333 weeks per month. 4.3333333 * 7 = 30.3333333 DAYS per month
so if you want to add one month you need to add the following number of milliseconds to the date:
1000 * 60 * 60 * 24 * 30.33333333 = 2620800000
var date1MonthsFrom Now = new Date(date.getTi me() + parseInt(30.333 3333*24*60*60*1 000));
And you will still be wrong. There are not 30.3333333 days in a month,
any month. So now you are wrong 6 out of 6 instead of 5 out of 6 times.
var date6MonthsFrom Now = new Date(date.getTi me() + (182*24*60*60*1 000));
so by adding 182 days, like mike has done here is the correct way to add "6 months"
No its not.
Please read the FAQ.
--
Randy This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: David Kuhn |
last post by:
I have a query with a date field criteria of:
Between And
When the query is run, I am asked for the Start date and then the End
Date. So far, so good.
The records returned are all those in between those dates and not
records that are on the start or the end date.
For example, I enter "09/01/03" for the start date and "09/30/03" for
|
by: CheezIt2831 |
last post by:
hello, I have 5 tables(Alpha, Bravo, Charlie, Service, Trans). What i am trying to do is be able to select a start date and ending date for a report and include fields from the 5 tables. this is my code:
SELECT , , , ,
FROM
UNION SELECT , , , ,
FROM
UNION SELECT , , , ,
FROM
UNION SELECT , , , ,
FROM
|
by: srikanthch3 |
last post by:
Hi
I had problem in comparision of the start date and end date vba in excell.if u give the end date 2/2/07 and start date 3/2/07, it is accepting.so any one can help.
Srikanth
|
by: Scott |
last post by:
I have a report that summarizes attendance occurances for my team of
50 employees. Right now the date values are entered by the user before
report execution.
I want the start date to be flexible... I built a query which shows
all reps on an active attendance write up (within the last 180 days).
I want the attendance report to use the query's write up date as the
start date for each employee (if an active write up exists), and if no...
|
by: Del |
last post by:
I have a parameter query that requires the user to enter a Start Date:
and End Date: and pull data between that date range. I am currently
using the following parameter;
Select *
From mytable
Where between and
This query will always be run on a Monday and the start date will
always be the previous Sunday. The end date will be the previous
| |
by: =?Utf-8?B?QW5pdGhh?= |
last post by:
Hi,
Currently for Announcement library a custom column "publish start date" is
added and under the search result webpart changed the xslt by filtering the
result based on the publish start date .Publish start date is not mandatory.
if the publish start date <"" and publish start date <= today then
the item get displayed under the search results
else
the item won't get displayed.
|
by: Tim Mullin |
last post by:
Hello all,
I'm hoping to find an answer to a question I have using forms in Access 2007.
I have a form (source: table) that has three fields:
Start Date
Term (number of months)
End Date
|
by: Jared Elyea |
last post by:
I had no experience in VB before writing this so bare with me...
the function below seems to work for certain cases, but not all (in some cases it is a week behind). Can anybody help me figure this out? It is supposed to take an integer(numDays) and a date and calculate the date that is "numDays" weekdays from the start date. I don't know if it is the if statement at the bottom or the particular cases that seem not to work.
Here it is it...
|
by: divya birla |
last post by:
Posted - 03/29/2011 : 06:34:20
I have a table which contain Topic, Sequence number and no of turns.
User input the Single Start date and on the basis of which
series of start date and end date is calculated.
Let start date= 1 Jan ,2011
then
Topic | Sequence number |NoOfTurns | Start date | end date
......................................................................
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |