Click to See Complete Forum and Search --> : Formatting date
janice
04-27-2004, 03:14 PM
This is probably simple but I need to pull our date from our access db in this format:
April 27, 2004
Currently, it is in this format:
04/27/2004
This isn't working:
varDate = CDate(rs("Date_Found"))
act.WriteLine("" & FormatDateTime(("varDate"),1) & )
Thanks in advance
buntine
04-27-2004, 06:11 PM
When you use quotes, the given string will be treated a string literal, apposed to a variable.
Try this.
varDate = CDate(rs("Date_Found"))
varDate = FormatDateTime(varDate, 1)
Response.Write(varDate)
Regards,
Andrew Buntine.
janice
04-28-2004, 09:27 AM
hi Andrew,
Thanks, that worked.
Only minor issue is that it displays day, day of week, mm/dd/yyyy.
As far as I am concerned, this is a minor issue but it would be nice to give the user the exact thing they asked for which is mm/dd/yearmwithout adding day of week like Wednesday, April 2004
buntine
04-28-2004, 10:43 AM
Ok, a quick and dirty solution may be to simply cut the unwanted part of the string.
varDate = CDate(rs("Date_Found"))
varDate = Split(FormatDateTime(varDate, 1), " ")(0)
Response.Write(varDate)
Im sure theres a better way, but this should work.
Regards,
Andrew Buntine.
janice
04-28-2004, 11:54 AM
Thanks alot Andrew, you have been of great help.
That didn't work though.
When I ran it, I got day of the week only, Wednesday.
But not to worry, it is ok the way it is now.
If they really insist, I will put in some more work into it.
buntine
04-29-2004, 01:31 AM
Ok, i actually came up with the solution. Just implement this code, it should work. Though, if the original date content day names, etc, it may not deprecate them.
varDate = CDate(rs("Date_Found"))
varDate = FormatDateTime(varDate, 0)
Response.Write(varDate)
Regards,
Andrew Buntine.