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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove characters from the end of a string

Status
Not open for further replies.

shangrilla

Programmer
Nov 21, 2001
360
US
Hi:

I want to remove a certain # of characters from the end of a string.

2/2/2002 12:00:00 AM should be 2/2/2002
12/12/2002 12:00:00 AM should be 12/12/2002

Any help appreciated.
 
Hi:

Ignore my first post. I think if the following can be achieved than it'll be more helpful.

How can I convert "2/13/2002 12:00:00 AM" to 2002132
and also "12/31/2002 12:00:00 AM" to 20021231

Thanks
 
you want to go from US style dates to ISO dates?

i.e., MMDDYYYY to YYYYMMDD?

here's one way:
[tt]
function usToIso(sDate) {
dDate = new Date(sDate);//alert(dDate)
return dDate.getFullYear().toString() +
((dDate.getMonth() + 1 < 10)?&quot;0&quot;+(dDate.getMonth()+1):(dDate.getMonth()+1)).toString() +
((dDate.getDate() < 10)?&quot;0&quot;+dDate.getDate():dDate.getDate()).toString();
}
[/tt]





================================================================================================= =========================================================
while (!succeed) try();
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top