Parsing date from sql string in asp.net, then comparing it with present date

Discussion in 'ASP .Net' started by .Net Sports, Jun 24, 2005.

  1. .Net Sports

    .Net Sports Guest

    I need to parse the date I'm getting from this sqlstring to compare it
    with today's date. If it's before today's date, i need to show the
    viewers one page. If it is after today's date, then I need to show
    viewers another page.
    ''''''''
    Dim strConn2 as string
    ="SERVER=xxx.xx.xx.x;UID=xxxx;PWD=xxxx;DATABASE=mydbase;"
    Dim strSQL2 as string ="SELECT articledate,articleheader,articleID
    FROM media WHERE author = 99 AND articledate =(SELECT MAX(articledate)
    FROM media WHERE handid = 99)"
    Dim Conn2 as New SQLConnection(strConn2)
    Dim Cmd2 as New SQLCommand(strSQL2,Conn2)
    Conn2.Open()
    thedata2.DataSource =
    Cmd2.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    thedata2.DataBind()
    end sub
    ''''''''

    but I'm stuck as how to use the articledate from this resultset for the
    comparison.
    ??????
    ..NetSports
     
    .Net Sports, Jun 24, 2005
    #1
    1. Advertising

  2. .Net Sports

    intrader Guest

    On Fri, 24 Jun 2005 13:28:09 -0700, .Net Sports wrote:

    > I need to parse the date I'm getting from this sqlstring to compare it
    > with today's date. If it's before today's date, i need to show the
    > viewers one page. If it is after today's date, then I need to show
    > viewers another page.
    > ''''''''
    > Dim strConn2 as string
    > ="SERVER=xxx.xx.xx.x;UID=xxxx;PWD=xxxx;DATABASE=mydbase;"
    > Dim strSQL2 as string ="SELECT articledate,articleheader,articleID
    > FROM media WHERE author = 99 AND articledate =(SELECT MAX(articledate)
    > FROM media WHERE handid = 99)"
    > Dim Conn2 as New SQLConnection(strConn2)
    > Dim Cmd2 as New SQLCommand(strSQL2,Conn2)
    > Conn2.Open()
    > thedata2.DataSource =
    > Cmd2.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    > thedata2.DataBind()
    > end sub
    > ''''''''
    >
    > but I'm stuck as how to use the articledate from this resultset for the
    > comparison.
    > ??????

    I would have:
    Dim DR as SqlDataReader
    DR = Cmd2.ExecuteReader(system.data.CommandBehavior.CloseConnection)
    ' The date is in articleDate in your data reader as
    (string)DR("articleDate")

    You can compare with Now.

    > .NetSports
     
    intrader, Jun 25, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Kirkeby
    Replies:
    1
    Views:
    566
    Anthony Borla
    Dec 3, 2003
  2. Ralf Wahner
    Replies:
    5
    Views:
    655
    Bob Foster
    Dec 24, 2003
  3. Belinda
    Replies:
    4
    Views:
    394
    Bob Barrows [MVP]
    Jun 11, 2004
  4. Les Juby
    Replies:
    3
    Views:
    222
    Bob Barrows [MVP]
    Apr 24, 2005
  5. Replies:
    0
    Views:
    340
Loading...

Share This Page