compare date field to current date

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Haas

    compare date field to current date

    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

    #2
    Re: compare date field to current date

    Try using DateDiff

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


    "Michael Haas" <mhaas@mail.lr. k12.nj.us> wrote in message
    news:16d45a75.0 402150751.1ce20 564@posting.goo gle.com...[color=blue]
    > 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[/color]


    Comment

    • Mike Haas

      #3
      Re: compare date field to current date


      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!

      Comment

      • Aaron Bertrand [MVP]

        #4
        Re: compare date field to current date

        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
        Please contact this domain's administrator as their DNS Made Easy services have expired.





        "Mike Haas" <mhaas@mail.lr. k12.nj.us> wrote in message
        news:u8IyUm#8DH A.1816@TK2MSFTN GP12.phx.gbl...[color=blue]
        >
        > 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![/color]


        Comment

        • Mike Haas

          #5
          Re: compare date field to current date


          That did the trick, thanks


          *** Sent via Developersdex http://www.developersdex.com ***
          Don't just participate in USENET...get rewarded for it!

          Comment

          Working...