+ Reply to Thread
Results 1 to 5 of 5

Thread: date problem

  1. #1
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    889
    Rep Power
    4

    date problem

    hello,

    Code:
    datetoday=Date()
    
    sdate=rs("Startdate")
    edate=rs("EndDate")
    
    What I want to do is if datetoday is between the sdate and edate then set a variable

    here is the code
    Code:
    If datetoday >= sdate and datetoday <= edate then
    	setflag="1"
    else
    	setflag="2"
    End if
    
    but its saying setflag="2"

    in the table the value of sdate="1/2/2010" and edate="4/11/2010"

    any idea what i am doing wrong

    todd

  2. #2
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    What is the output of:
    Code:
    Response.Write(datetoday & "<br />")
    Response.Write(sdate & "<br />")
    Response.Write(edaate & "<br />")
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


  3. #3
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    889
    Rep Power
    4

    datetoday:3/10/2010
    sdate:1/2/2010
    edate:4/11/2010

  4. #4
    Barn Loyal todd2006 is an unknown quantity at this point todd2006's Avatar
    Join Date
    Mar 2008
    Posts
    889
    Rep Power
    4

    startdate and enddate fields datatype is datetime in the database

  5. #5
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,547
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Try:
    Code:
    If DateDiff("d", sdate, datetoday) >= 0 And DateDiff("d", edate, datetoday) <= 0 Then
        setflag = 1
    Else
        setflag = 2
    End If
    
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


+ Reply to Thread

Similar Threads

  1. date problem
    By todd2006 in forum SQL Development
    Replies: 7
    Last Post: May 15th, 2009, 04:27 AM
  2. Date problem
    By todd2006 in forum ASP Development
    Replies: 11
    Last Post: March 9th, 2009, 03:49 PM
  3. Date problem
    By todd2006 in forum ASP Development
    Replies: 1
    Last Post: September 1st, 2008, 07:15 PM
  4. date problem
    By todd2006 in forum SQL Development
    Replies: 2
    Last Post: July 7th, 2008, 02:52 PM
  5. date problem
    By todd2006 in forum SQL Development
    Replies: 1
    Last Post: May 12th, 2008, 02:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO