Click to See Complete Forum and Search --> : Convert Datetime Data type to String


red_jedi2004
04-20-2006, 04:11 AM
Hi,

I am supposed to display a datetime datatype from a database to an asp page. But it seems that it only displays the date, without the time. Could anyone help me?

<Eddie>
04-20-2006, 06:25 AM
Check out http://www.codetoad.com/asp/format_date_time.asp .

Terrorke
04-20-2006, 07:13 AM
another one that might be handy :

http://www.w3schools.com/vbscript/vbscript_ref_functions.asp#date

Ubik
04-20-2006, 09:06 PM
I use:


Function GoodDate(thedate)
if trim(thedate&" ")<>"" then
if isdate(thedate) then
thedate=dateadd("n", 0, thedate)
GoodDate=weekdayname(weekday(thedate,vbMonday),1,vbMonday)&", "&day(thedate)&" "&MonthName(Month(thedate), 1)& " "& Year(thedate)
Else
GoodDate=thedate
End If
Else
GoodDate=thedate
End If
End Function

Function Goodtime(thetime)
if not isdate(thetime) then
Goodtime="[invalid date/time]"
Else
BY_hour=hour(thetime)
BY_min=minute(thetime)
If BY_hour >= 13 then
BY_ampm="pm"
BY_hour=BY_hour-12
elseif BY_hour = 12 then
BY_ampm="pm"
elseif BY_hour = 0 then
BY_ampm="am"
BY_hour=12
else
BY_ampm="am"
End If
If BY_min < 10 then
BY_min="0"&BY_min
End if
Goodtime=BY_hour&":"&BY_min&BY_ampm
End If
if isnull(thetime) then
Goodtime=""
End If
End Function