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!

DateTime Function?? PLEASE HELP

Status
Not open for further replies.

zishan876

Programmer
Mar 19, 2007
61
US
Hi all, Happy Holidays...
Ok I have a datetime field in my query which comes out like so:
2008-12-10T16:39:00.000Z

The actual datetime looks like so:
12/10/2008 10:39 AM

How do I change it or format it correctly to update a field in my other table...

I am querying off Table1 to get the info to place into query2 but taking it from the URL..
so my URL comes up with

...&00NR0000000IFVW=2008-12-10T16:39:00.000Z&00NR0000000IFTz=2008-12-12T02:01:00.000Z&00NR0000000IGeK=Customer revenue...

When it tries to update the field I get the error stating
Error: Invalid Date and Time

Please help... Thanks
 
Assuming it is, you start with a string, 2008-12-10T16:39:00.000Z

Now you can parse it out to make a valid JS date.
First I think I'd split on the T
Code:
a="2008-12-10T16:39:00.000Z".split(/T/)
now in a[0], replace "-" with "/"
Code:
b=a[0].replace(/[\x2d]/g,'/')
Now you have to change "Z" to " GMT" [note the space] and add the time part back with a space:
Code:
b=b + ' ' + a[1].replace(/Z/," GMT")
and make it a valid JS Date object:
Code:
c = Date.parse(b)
and manipulate that date however you like.



_________________
Bob Rashkin
 
Awesome, How do I eliminate the GMT and place in AM PM?? Cool Thanks
Happy Holidays
 
Check this out:
Code:
var d="12/18/08 12:42 gmt";
var t=new Date(d)
alert(t.toLocaleString())

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top