Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS Access, Javascript and Dates 1

Status
Not open for further replies.

Jouster

Programmer
Dec 4, 2000
82
US
Hi,

I am reading a date/time field from an Access DB with ASP Javascript. The field in the database is set to short date like 1/2/08.

When I display the record on the web page with this code : <%=objSPF.Fields.Item("Expiration").Value%> I keep getting this long date like: Mon June 5 00:00:00 EDT 2008

Does anyone knnow how I get around this and just display the short date?

thanks for the help.
 
[1] You can do something like this as a preparation.
[tt]<%
var d,dd;
//a bit of twist due to the uncertainty of the data type retrieved; maybe you can spare/simplify it
d=new Date(Date.parse(objSPF.Fields.Item("Expiration").Value));
dd=(d.getMonth()+1) + "/" + d.getDate() + "/" + d.getFullYear();
%>[/tt]
[2] Then display the controlled formatted string dd at its place.
[tt] <%=dd%>[/tt]
 
Thank you for your help. That worked great!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top