Date conversion funtion 1: We get the date in dd/mm/yyyy through a form.
But different database accept different date formats.
One thing is common among various databases. they will always accept if the date is in the format: 31-
December-2013
So whenever we are going to insert a date, you can use this function.
<%
function ddmmyy_to_database(this_date)
'input format is 31/12/2013
'output format is 31-December-2013
dim dd_this_date,mm_this_date,yy_this_date
if this_date="" or this_date="//" then
ddmmyy_to_database=""
else
date_array=split(this_date,"/")
dd_this_date=date_array(0)
if dd_this_date <10 p="" then=""> dd_this_date="0" & cint(dd_this_date)
end if
mm_this_date=date_array(1)
mm_this_date=monthname(mm_this_date)
yy_this_date=date_array(2)
ddmmyy_to_database=dd_this_date & "-" & mm_this_date & "-" & yy_this_date
end if
end function
%>
=========================================================
In the same way, when we take out the date from the database and displaying, we can use this function:
<%
function ddmmyy_from_database(this_date)
'input format we need not know
'output format is 31/12/2013
dim dd_this_date,mm_this_date,yy_this_date
if not isdate(this_date) then
ddmmyy_from_database=""
else
dd_this_date=day(this_date)
if dd_this_date <10 p="" then=""> dd_this_date="0" & dd_this_date
end if
mm_this_date=month(this_date)
if mm_this_date <10 p="" then=""> mm_this_date="0" & mm_this_date
end if
yy_this_date=right(year(this_date),2)
ddmmyy_from_database=dd_this_date & "/" & mm_this_date & "/" & yy_this_date
end if
end function
%>
=====================================================