LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-15-2005, 07:46 AM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
Subtracting the day of two dates and recieving an integer answer(VB.NET)


I am using the following code to populate a listbox with id numbers with dates appended to them:

Code:
Dim coilid, x As String
            x = DateTime.Today

            For q = 0 To CoilPDIRowCount - 1
            lstcoilpdi.Items.Add((PDIDataset.Tables("Table2").Rows(q).Item("ID")) + " (" + x + ")")
            lstcoilpdi.Items.Add(q)
             Next
I want to be able to create the effect that if an Id has been in the listbox for more than two days, remove it from the listbox. I am trying to find a way to to take the current date and subract from it the date that the id entered the listbox(i.e. x in this case). Does anyone know how to do this?
 
Old 08-15-2005, 01:46 PM   #2
tekkieman
Member
 
Registered: Dec 2004
Location: Northern CA
Distribution: Mepis 6.5
Posts: 123

Rep: Reputation: 15
This should give you something to go on...

Code:
strDate1 = "August 12, 2005"
        datDate1 = DateTime.Parse(strDate1)
        datDate2 = DateTime.Today.AddDays(-2.0)

        If (DateTime.Compare(datDate1, datDate2) > 0) Then
            MsgBox("Date 1 > Date 2")
        ElseIf (DateTime.Compare(datDate1, datDate2) = 0) Then

            MsgBox("Date 2 = Date 1")

        Else
            MsgBox("Date 2 > Date 1")
        End If
You just need to parse the date from the listbox item and cast it to a DateTime type to do the DateTime.Compare.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What applications do you use day to day? alan_h404 General 11 10-16-2005 07:09 AM
Why not use Astaro as a normal day to day desktop?? chutsu Linux - General 1 10-08-2005 11:42 PM
DAY 1 on SUSE92: Autodial net upon Konqueror request? Premadonna Linux - Newbie 1 07-15-2005 12:26 PM
Subtracting dates chrisk5527 Linux - General 6 06-10-2004 02:57 PM
How am I recieving blank emails? tarballedtux Linux - General 3 02-21-2004 10:13 AM


All times are GMT -5. The time now is 02:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration