[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Setting Date Problem

Posted on 2004-09-07
5
Medium Priority
?
178 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 8

Accepted Solution

by:
razo earned 1000 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 500 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 1000 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 500 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

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

656 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