-
May 3rd, 2010, 08:10 AM
#1
Thread Starter
Junior Member
Converting date and time format to date
Hi All,
I have a problem. I'm making a alarm clock and I need a way of converting a "dd/MM/yyyy HH:mm:ss" format into a date time format. This means I'll be able to compare the dates in a listbox using the for each function, to the current date and see whever it has passed and therfore the alarm should be deleted. It is currently in a string form so I can't use < and > to compare it to the current date as that is in a date form. I've tried using CDate but it doesn't work as it only will convert these formats:
"August 12, 2004", "2:07:30 PM" and "August 12, 2004 2:07:30 PM"
Can anyone help?
Thanks,
m1la
-
May 3rd, 2010, 08:34 AM
#2
Lively Member
Re: Converting date and time format to date
There's a few static members of the Date structure that can help your cause. Parse, TryParse, ParseExact, TryParseExact.
Code:
Dim MyDate As DateTime
If DateTime.TryParse("03/05/2010 11:23:21", MyDate) Then
'It worked
Debug.WriteLine(MyDate.ToString())
End If
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|