TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Priyamtheone
NA
63
0
Problem with DateTime matching.
May 7 2010 12:10 PM
I'm trying to match a certain DateTime value with the current system DateTime. I have a timer and a label on a form. Timer interval is set to 1000. When the form loads, the timer starts ticking. As soon as the current DateTime matches the value of the variable, it shows a message in the label.
When I'm writing the following code, the values don't match even if the current system DateTime is equal to the variable. Label1 isn't showing 'Times Matched':
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim dtmNow As DateTime
dim dtmVar as DateTime=#04/28/2010 03:25:00 AM#
dtmNow = Now
If dtmVar = dtmNow Then Label1.Text = "Times Matched"
End Sub
But when I'm writing the same code by parsing 'Now' into DateTime it's working fine.
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim dtmNow As DateTime
dim dtmVar as DateTime=#04/28/2010 03:25:00 AM#
dtmNow = DateTime.Parse(Now.ToString)
If dtmVar = dtmNow Then Label1.Text = "Times Matched"
End Sub
Why is it so? The default format of 'Now' is the same as I have stored in dtmVar variable. So there's no question of format mismatch. Does that mean 'Now' is not actually a DateTime property?
Provided, my O.S. is Windows Vista Ultimate and all date/time settings are set to default.
Regards.
Reply
Answers (
2
)
use custom application in my own application
Problem in setting DateTime value explicitly.