WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE
CDate formats the string(dSomeDate) to a date. The IF THEN statement
checks to see if the date is < NOW (NOW returns the computers
current date and time). If TRUE Runs the first Argument.If it is
not TRUE then the second Argument is run, ASP makes converting string
to date very easy. We're going to use the CDate ASP/VBScript function
in our ASP code to convert a string to a date value. ASP CDate function
has 1 string argument, which is the string to be converted to date.
The CDate function converts any valid date/time string expression
to Date variant subtype. The CDate function converts a valid
date and time expression to type Date, and returns the result.
The Syntax CDate function is :-
Example#1 :-
Code :-
<%
sDate = "January 13, 1970"
Response.Write CDate(sDate)
%>
Output :-
1/13/70 |
Example#2 :-
Code :-
d="April 22, 2001"
if IsDate(d) then
document.write(CDate(d))
Output :-
2/22/01 |
Example#3 :-
Code :-
d=#2/22/01#
if IsDate(d) then
document.write(CDate(d))
Output :-
2/22/01 |
Example#4 :-
Code :-
d="3:18:40 AM"
if IsDate(d) then
document.write(CDate(d))
Output :-
3:18:40 AM |
|