Solved

Setting Date Problem

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Tabcontrol Caption? 1 29
Closing all open child forms. 4 38
update textboxes with Streamreader 21 42
Close tabpage of custom control 9 23
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

912 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

16 Experts available now in Live!

Get 1:1 Help Now