compare date field to current date

Discussion in 'ASP General' started by Michael Haas, Feb 15, 2004.

  1. Michael Haas

    Michael Haas Guest

    Need some hwlp with comparing a date field retrieved from an access
    date base to the current date. Basically I'm looking to create and if
    statement like:
    If strArticleDate < = Current Date then
    else...

    Thanks for any help or feedback
    Mike
     
    Michael Haas, Feb 15, 2004
    #1
    1. Advertising

  2. Michael Haas

    Tom B Guest

    Try using DateDiff

    if DateDiff("d",strArticleDate, CurrentDate)>0 then
    'whatever


    "Michael Haas" <12.nj.us> wrote in message
    news:...
    > Need some hwlp with comparing a date field retrieved from an access
    > date base to the current date. Basically I'm looking to create and if
    > statement like:
    > If strArticleDate < = Current Date then
    > else...
    >
    > Thanks for any help or feedback
    > Mike
     
    Tom B, Feb 15, 2004
    #2
    1. Advertising

  3. Michael Haas

    Mike Haas Guest

    I'm having a problem witht he currentdate part:
    if I substitute "02/15/2004" for CurrentDate it works
    Do I need to format CurrentDate? how should I decalre it?
    Thanks for the help again.
    Mike

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Mike Haas, Feb 15, 2004
    #3
  4. You shouldn't have to worry about formatting.

    WHERE dateColumn <= Date()

    or better yet, if dateColumn has time information,

    WHERE dateColumn < DATEADD("d", 1, Date())

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/




    "Mike Haas" <12.nj.us> wrote in message
    news:u8IyUm#...
    >
    > I'm having a problem witht he currentdate part:
    > if I substitute "02/15/2004" for CurrentDate it works
    > Do I need to format CurrentDate? how should I decalre it?
    > Thanks for the help again.
    > Mike
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Aaron Bertrand [MVP], Feb 15, 2004
    #4
  5. Michael Haas

    Mike Haas Guest

    That did the trick, thanks


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Mike Haas, Feb 15, 2004
    #5
    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. James P.
    Replies:
    7
    Views:
    12,523
    phamtasmic
    Jul 13, 2004
  2. CZ
    Replies:
    1
    Views:
    702
    Jack Li
    Sep 23, 2005
  3. Replies:
    8
    Views:
    229
    peashoe
    Jan 24, 2005
  4. Sound
    Replies:
    2
    Views:
    453
    Randy Webb
    Sep 28, 2006
  5. jr
    Replies:
    3
    Views:
    426
Loading...

Share This Page