?
Solved

complex excel date calculation issue

Posted on 2011-11-01
7
Medium Priority
?
316 Views
Last Modified: 2012-05-12
hi
one of my developer is working on some automation currently there is a column on the excel which has a date and the program increment date on each data row now this program works perfectly fine on his pc however when i try on my pc it doesnt work i have tried like 4 pc so far but all have the same issue

it is adding month instead of days

previous sheet dates
26-Dec-11                  27-Dec-11                  28-Dec-11                  29-Dec-11                  30-Dec-11                  31-Dec-11                  1-Jan-12      

                  

generated sheets dates
1-Feb-12                  1-Mar-12                  1-Apr-12                  1-May-12                  1-Jun-12                  1-Jul-12                  1-Aug-12            

the image shows the code used.


thanks
            

date.png
0
Comment
Question by:mattibutt
  • 4
  • 2
7 Comments
 
LVL 24

Accepted Solution

by:
mankowitz earned 1600 total points
ID: 37062290
Why do you parse and convert to string? Couldn't you just accomplish the same by doing this:

lastdate = lastdate.adddays(1);

0
 
LVL 11

Author Comment

by:mattibutt
ID: 37062406
hi
its a bit hectic process problem is it works perfectly fine on his pc but when i try now i have tried 5 pc in my network all produce the same result what you are saying can work globally then i can tell him to try that.
thanks
0
 
LVL 24

Expert Comment

by:mankowitz
ID: 37062592
my suspicion is that when you convert it to a string, you are putting the month in the day place, and then, when you parse it back, it gives the wrong answer. I suspect that the default setting on his computer is to have d-m-y instead of m-d-y (or vice versa)
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
LVL 11

Author Comment

by:mattibutt
ID: 37062687
how can i change my settings on my computer so i can fix the issue without changing the codes.
thanks
0
 
LVL 11

Author Comment

by:mattibutt
ID: 37063119
hi
i have tried all date formats it still doesnt work
0
 
LVL 8

Assisted Solution

by:Wiesje
Wiesje earned 400 total points
ID: 37069143
I agree with mankowitz - you should use a different function to add the date - as in, you shouldnt use the string conversion back and forth.

By adding a day as date, it should work.

0
 
LVL 11

Author Closing Comment

by:mattibutt
ID: 37077007
after he changed the function the date now works fine on my pc

thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question