Solved

Setting Date Problem

Posted on 2004-09-07
5
174 Views
Last Modified: 2010-04-23
Hi guys I have a problem with setting a date.  I am defining two starting dates and then trying to calculate an ending date automatically.

I first define my two starting dates (dd/mm/yyyy    Australian format):

dim startDate01 as date = "1/07/2004"
dim startDate02 as date = "1/08/2004"

then I want an ending date for 'StartDate01' - this has to be '30/07/2004'

so I do the following:

dim endDate01 as date = DateAdd("d", -1, startDate02)

and the result I get is:

'30/07/2009'

So the day and month calculation is correct but why is my year now incremented by 5 years?

0
Comment
Question by:jakekula
5 Comments
 
LVL 8

Accepted Solution

by:
razo earned 250 total points
ID: 12003974
it worked perfectly fine
by the way it shoulld give 31/07/2004
can u post all ur code
0
 
LVL 10

Assisted Solution

by:123654789987
123654789987 earned 125 total points
ID: 12004335
This code gave me the right answer.

Try this

Dim startDate01 As Date = "07/01/2004"
        Dim startDate02 As Date = "08/01/2004"

        Dim endDate01 As Date = DateAdd("d", -1, startDate02)

        MessageBox.Show(endDate01.ToString)


As u see I have changed the format of the startDate. It is expecting the date to be in this format
0
 
LVL 8

Assisted Solution

by:razo
razo earned 250 total points
ID: 12004538
i used the australian format and it worked...so i think the error is caused b something else
0
 
LVL 14

Assisted Solution

by:Farzad Akbarnejad
Farzad Akbarnejad earned 125 total points
ID: 12004775
Hello,
I tested with English (Austrial) in Regional Settings in Control panel and got:  31/07/2004.
post your code here and let us know your Regional Settings of your Control Panel.

Thanks
-FA
0
 

Author Comment

by:jakekula
ID: 12012265
Thanks guys, the problem was actually something else, I'll split the point between the four of you.

Cheers,

JK
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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