Solved

Setting Date Problem

Posted on 2004-09-07
5
172 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now