Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET DateTime VB.NET
Dear All,
 
I am using the following code in two places in my ASP.NET Website.
 
1. In the Webpage - In Button.Click Event
2. Defined as a Function in a module in the website
 
Code Used:
Dim n as Date
n = DateAdd(DateInterval.Month, 1, Now())
Msgbox ("Now it is " & now() & ", Due Date is " & n)
When this code is executed in situation 1, I get the following output
Now it is 11/25/2012 14:35:00, Due Date is 12/25/2012 14:35:00
 
But when the same code is executed in situation 2, I get the following output
Now it is 11/25/2012 14:35:00, Due Date is 12:00:00
 
Pl advice where I am going wrong.
 
Thanks and regards.
 
[Edit]Code block added[/Edit]
Posted 25-Nov-12 6:40am
Edited 25-Nov-12 7:00am
ProgramFOX131.3K
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Have you tried to debug and see what value comes in n?
 
You can try using ToString function as follows:
Msgbox ("Now it is " & now().ToString("dd/MM/yyyy") & ", Due Date is " & n.ToString("dd/MM/yyyy"))
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 Sergey Alexandrovich Kryukov 174
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 26 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100