Click to See Complete Forum and Search --> : format database date


chrismartz
10-07-2004, 10:04 AM
anyone know how to format a date that was sent to the database. what i have is dates in my database like 10/7/04 and I would like to format these to October 7, 2004....anyway to do this? I call the date 10/7/04 with <%= rs.fields("whenpost") %>

buntine
10-07-2004, 10:34 AM
VBScript has a date and time formatting function which may be helpful. MS Access has a horrible habit of formatting dates oddly. It uses the systems ragional settings to auto-format dates.

Anyway, heres the code:

FormatDateTime(rs.fields("whenpost"), 1)

Regards.

chrismartz
10-07-2004, 11:42 AM
thank you very much buntine, how do i get rid of the seconds though in a time format like hh:mm?
<%= FormatDateTime(rs.fields("whenpost"),3) %> but that shows the seconds!

David Harrison
10-07-2004, 03:24 PM
Here is one of the functions from my blog (modified to remove the seconds):dim iday, arrDays, arrMonths, arrTop, sup, d

arrDays=Array("","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
arrMonths=Array("","January","February","March","April","May","June","July","August","September","October","November","December")
arrTop=Array("st","nd","rd")

function fulldate(gbdate)

if (Day(gbdate) mod 10)>3 OR (Day(gbdate) mod 10)=0 OR Day(gbdate)=11 OR Day(gbdate)=12 OR Day(gbdate)=13 then
sup="th"
else
sup=arrTop((Day(gbdate) mod 10)-1)
end if

fulldate=arrDays(Weekday(gbdate))&" "&Day(gbdate)&"<sup>"&sup&"</sup> "&MonthName(Month(gbdate), False)&" "&Year(gbdate)&" at "&iif(Hour(gbdate)>12, Hour(gbdate)-12, Hour(gbdate))&":"&iif(Minute(gbdate)<10, "0"&Minute(gbdate), Minute(gbdate))&" "&iif(Hour(gbdate)>12, "PM", "AM")

end functionTo use the function just do something like this:response.write "Here is a date" & fulldate(YOUR DATE HERE)Hope this helps. :)

chrismartz
10-07-2004, 04:24 PM
why can't microsoft get the hint and make like ,5 for the datetime function?

buntine
10-07-2004, 09:44 PM
Because they are lazy and have abandoned ASP.

chrismartz
10-07-2004, 10:10 PM
stupid asp.net....why abandon something so good!

buntine
10-08-2004, 03:38 AM
ASP aint' that good. Its rather primitive compared to the newer technologies.