Jump to content

parse values from date in the form of 1/1/1900


ConfusedGrayMatter

Recommended Posts

Besides using the substring, how do I seperate the values from this datetime datatype.I'm using an asp Jscript page to bring in the value and I am returning a date like 1/1/1900 or 12/16/2004 and I don't know how to correctly use javascript to seperate the month, day and year for use as individual variables.Thanks for your time.

Link to comment
Share on other sites

Thank You.Well, now I feel like a blockhead. Once I saw that example it clicked.In case someone else finds this thread looking for a similar answer to this kind of question, I thought I'd write a quick little block of code to perhaps make it even more simple.<%var BirthDay = String("8/10/2004");var bDate = new Date(BirthDay);var bMonth = bDate.getMonth() + 1;var bDay = bDate.getDate();var bYear = bDate.getYear();Response.Write("Birthday: " + BirthDay);Response.Write("<br>");Response.Write("Birth Month: " + bMonth);Response.Write("<br>");Response.Write("Birth Day: " + bDay);Response.Write("<br>");Response.Write("Birth Year: " + bYear);%>Results are:Birthday: 8/10/2004Birth Month: 8Birth Day: 10Birth Year: 2004 Thanks again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...