|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
working with time onlyIf I want to check to see if it's after "11:36 pm" what would I write?
I'm sure it's easy but I'm getting tired of having to work with dates and times. Sometimes I just want time or date. And to be able to do comparisons on them. Hi CJ,
Thanks for your post! The time in the day is logically associated with the date. So you can first get the exact time then get rid of the date party of the time. Below code snippet shows a sample to do this: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dt1 As DateTime = DateTime.Now Dim dt2 As DateTime = New DateTime(dt1.Year, dt1.Month, dt1.Day, 23, 36, 0) If (DateTime.Compare(dt1, dt2) > 0) Then MessageBox.Show("Current time is greater than 11:36 PM") End If End Sub Hope this helps! Best regards, Jeffrey Tan Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. cj,
If you initialize a new datetime than it is initial set to the start of the christian calender 01-01-01 00:00:00 Therefore if you ignore the datepart in your program you have just a time and can work with them. As forever you have to show dates and time to use the overloaded function of ToString which is in the DateTime. http://msdn2.microsoft.com/en-us/library/ht77y576.aspx I hope this helps, Cor Show quoteHide quote "cj" <cj@nospam.nospam> schreef in bericht news:eiceVyyjGHA.4660@TK2MSFTNGP03.phx.gbl... > If I want to check to see if it's after "11:36 pm" what would I write? > > I'm sure it's easy but I'm getting tired of having to work with dates and > times. Sometimes I just want time or date. And to be able to do > comparisons on them.
best way for Replace insensitive in strings
Newbie question on comboboxes Problem connecting to SQL Server Inserting Variables in a Document Help registering a dll Executing a SQL2005 Stored Procedure vb.net code for advanced data structures VB6 to VB2005 question about Frame control How do I load HTML into an instance of SHDocVw.InternetExplorer Help! Monitoring Process with Different Threads Error |
|||||||||||||||||||||||