If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > date compare problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-05, 02:47
eksanjay eksanjay is offline
Registered User
 
Join Date: Dec 2005
Posts: 8
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
Reply With Quote
  #2 (permalink)  
Old 12-29-05, 04:17
dimis2500 dimis2500 is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 12-29-05, 17:25
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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.
Reply With Quote
  #4 (permalink)  
Old 01-05-06, 02:17
eksanjay eksanjay is offline
Registered User
 
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.... ...
Reply With Quote
  #5 (permalink)  
Old 01-05-06, 16:36
rokslide rokslide is offline
Registered User
 
Join Date: Nov 2003
Location: Christchurch, New Zealand
Posts: 1,617
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On