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

Date Caculation returning incorrect answers

Hi Team,

This is my first post to this site and in fact any Javascript site. I have a problem which is strange, well strange to me anyway.

I have a grid on a form that displays all of the days in the week for a particular week ending date (Sunday). To calculate which date is the week ending (Sunday) for the next week I do the following:

var weekEndingParts = table.rows[7].cells[0].innerText.split("/");
var weekEnding = new Date(weekEndingParts[2], weekEndingParts[1] -1, weekEndingParts[0]);

nextWeekEnding = new Date(weekEnding.valueOf() + (7 * 86400000));

The works famously until it gets to two months .. October 2006 and Aril 2007. The only thing I can determine is different about these months is that they both have the 1st of the month on a Sunday.

Even stranger is that if I set the date at October 28th 2006 and simply add 86400000 to it the date jumps to October 30th 2007. October 29th seems to be totaly skipped.

Any ideas?

My only thought is that it's some environmental date setting that I am unaware of.

I look forward to your replies.

Cheers,
Danny
Mar 15 '07 #1
1 1086
acoder
16,027 Expert Mod 8TB
Welcome to TSDN.

Can you show the format of the dates that you are using.

If I add one day to October 28th 2006, I get October 29th. However, for October 2007, I get October 29th 2007 (23:00) which seems to suggest daylight saving is causing a problem. Do you have daylight saving where the hours go back or forward one hour where you live? Is it for April and October?
Mar 15 '07 #2

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

Similar topics

3
by: Leader | last post by:
Hi All, I am facing a problem with a sql what i used in MS Access but its not returning the same result in MS Sql Server 2000. Here i am giving the sql: SELECT TOP 3 format( MY_DATE, "dddd mm,...
1
by: John Norvell | last post by:
I just noticed that recently the javascript I was using to format and display the last modified date of my web page is always reporting the current date instead. It used to work fine. This is true...
13
by: Deano | last post by:
Hi, I generate a report using two dates (From and To). I notice if I enter 01/10/2003 that it is interpreted by Access as 10/01/2003 i.e 10th January rather than 1st October as I intended. ...
5
by: Ray | last post by:
I have a table with some audit date and time columns. Problem is the developer who stored the data left them as DECIMAL type instead of DATE and TIME. Is there a way I can convert the DECIMAL type...
3
by: RJA | last post by:
Hiyas, Using VS .net 2003. Setting up a Webservice that accepts 3rd party vendor designed XML requests and returns a filled XMLDocument with response data. Vendor XSDs were serialize into...
44
by: user | last post by:
Hi, Let's say I have 2 dates in the b/m format: Date 1 and date 2 How do I check whether Date2 is later than Date 1? Date1. 21-Nov-2006 09:00:00 PM
6
by: awojciehowski | last post by:
I am working with a database now and need some guidance. I am attempting to input an auto calculation. I have the ability to enter a date in a text box on a form. I want to be able to have...
1
by: Yew12 | last post by:
Ok I have a date field called ADATE and I want to add the column "Duration(Min)" to this date. I have had ago at the code but it still doesn't work. I have tried dividing the added...
4
by: OzNet | last post by:
I have some functions to calculate the working days in a given period. This includes a table that is queried to calculate the number of public holidays that don’t occur on a weekend. If I test...
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:
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
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: 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
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
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...

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.