473,387 Members | 1,512 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.

How can I calculate date plus or minus n days

I have n days and a date, I want a date plus(or minus) to n days.How can I do that in javascript
May 10 '07 #1
4 11528
dmjpro
2,476 2GB
Welcome to TSDN.............

have a look on ............ http://www.w3schools.com/jsref/jsref_obj_date.asp

then try ..............
Expand|Select|Wrap|Line Numbers
  1. Date D = new Date();
  2. D.setDate(D.getDate()+33)
best of luck.
kind regards.
May 10 '07 #2
Thank you very much

I have another solution :
Expand|Select|Wrap|Line Numbers
  1. Date.prototype.addDays =
  2.          function(days)
  3.          {
  4.             return new Date(this.getTime() + days * 24 * 60 * 60 * 1000);
  5.          }
Best regrad
May 10 '07 #3
dmjpro
2,476 2GB
good to see you r handling the JS inheritence properties.....

best of luck with ur talent.
kind regards.
May 10 '07 #4
aruun
1
@tamnguyet
Your solution fixed my searching to end, it fulfilled my search
Mar 11 '15 #5

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

Similar topics

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: cvisal | last post by:
Hi all Im working on productivity calculations (Time calculations) and need some help in coding. Database Tool:MS-Access 2003. The general operator punch-in time is 5:30 AM and the punch-out...
13
by: maflatoun | last post by:
Hi, I have the following function to convert UTC time to Local time. It works perfect for GMT- (Minus) time zones however it provides incorrect results for GMT+(Plus) time zones? // Format to...
7
by: No bother | last post by:
I have a table which has, among other fields, a date field. I want to get a count of records where certain criteria are met for, say, three days in a row. For example: NumWidgets Date...
9
by: bibaudj | last post by:
I'm trying to write a function to be used in a query - because I don't think it can be compiled directly in a query (using Expression Builder). This is for a holiday DB. I would like to determine...
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
18
by: saykenari | last post by:
Hello Friends I have a problem date format written as DD/MM/YYYY. Date already save into a file as binary. I don't know which technique should be used. Sample date as following a....
4
by: Vince | last post by:
Given a week Number, how do I calculate the date that for the Monday of that week?
8
by: trixxnixon | last post by:
I know this topic is a veritable dead horse, but I have to ask, because I am unable to find something that is close to my scenario that I can completely understand. I have a start date field ...
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: 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: 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...
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...
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
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.