Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: how do u convert a string to date? CDate doesnt work


Message #1 by bobby.sojitra@b... on Tue, 16 Apr 2002 11:45:45
Grr....

Hey dudes.

Heres what im trying to do :

I have a field in my database that holds a STRING value such 
as "11/11/1980". So for example in my asp page, i will grab this field 
like this : "strDate = rs.Fields("Date").Value". "strDate" now holds the 
STRING value "11/11/1980".

I also have a variable that holds today's date. This is how i have defined 
it :
        Session.LCID = 2057     'For English format date
	strToday = Now()
	strTodayDate = formatDateTime(strToday,2)

So now, i have "strDate" with the STRING value "11/11/1980" 
and "strTodayDate" with the DATE value "16/04/2002". 

I want to convert "strDate" to a DATE type so i can perform comparisons 
between "strDate" and "strTodayDate". I have tried the conversion 
function "CDate(strDate)" but that doesnt work.

Thanks dudes. My brain is only half switched on today...
Message #2 by Joe Ingle <Joe@k...> on Tue, 16 Apr 2002 12:42:43 +0100
why do you have to store the Date field as a string?? Why not use
smalldatetime?

Joe

-----Original Message-----
From: bobby.sojitra@b... [mailto:bobby.sojitra@b...]
Sent: Tuesday, April 16, 2002 12:46 PM
To: ASP Web HowTo
Subject: [asp_web_howto] how do u convert a string to date? CDate doesnt
work


Grr....

Hey dudes.

Heres what im trying to do :

I have a field in my database that holds a STRING value such 
as "11/11/1980". So for example in my asp page, i will grab this field 
like this : "strDate = rs.Fields("Date").Value". "strDate" now holds the 
STRING value "11/11/1980".

I also have a variable that holds today's date. This is how i have defined 
it :
        Session.LCID = 2057     'For English format date
	strToday = Now()
	strTodayDate = formatDateTime(strToday,2)

So now, i have "strDate" with the STRING value "11/11/1980" 
and "strTodayDate" with the DATE value "16/04/2002". 

I want to convert "strDate" to a DATE type so i can perform comparisons 
between "strDate" and "strTodayDate". I have tried the conversion 
function "CDate(strDate)" but that doesnt work.

Thanks dudes. My brain is only half switched on today...

---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20

  Return to Index