Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2005
    Posts
    8

    Unanswered: date compare problem

    Dear all

    i have date on web page in (dd-mon-yyyy) format
    and in database i m storing it as text

    Now i want to compare two dates cud u help out....
    feel free to mail on eksanjay@gmail.com

  2. #2
    Join Date
    Jan 2005
    Posts
    362

    Date

    I think there are 2 ways:
    1. Convert both to text (I thing it is so?), both having the right format and to compare them as text values.
    2. Convert both to dates and again to compare them as dates.
    dimis

  3. #3
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Sounds like you want option 2.

    The CDate function in VBScript is your friend in this case. It should work with the format you have.

    Why are you storing them as text in the database.

    Oh, if you want to do the comparison in at the database (rather then in the asp page) let us know what database you are using and we should be able to come up with something.

  4. #4
    Join Date
    Dec 2005
    Posts
    8

    Arrow wat is way.....

    Hi,
    Wat is the way to use that 'CDate' function and how to compare two dates.......... cud u plz show me some sort of code for dat.... ...

  5. #5
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    something like this....
    Code:
    date1 = "01-Jan-2005"
    date2 = "03-Jan-2005"
    
    if(CDate(date1) > CDate(date2)) then
      ' do some stuff
    else
      ' do some other stuff
    end if
    You also might want to check out the DateDiff function.... have a search on http://msdn.microsoft.com/library/ for more details

Posting Permissions

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