function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rock_chalkrock_chalk 

Problem passing date in URL

I hope someone can help with this because it has got me stumped.  I'm using an s-control to pull date field to determine the date when a task was started and when it was completed.

I'm using a soql query to return the date, and then passing that in a URL to update the field on the page.

My problem is that the date is returned in UTC format, which the page says is an invalid date format.  This is a sample of the date returned: 2008-06-30T19:28:25.000Z

I've tried everything I can think of to format this into a format the page will accept i.e. 2/23/2008 10:29 AM - but nothing has worked so far.  This is a snippet from the s-control:

var actEnd  = sforce.connection.query("Select Id, CreatedDate from Case_Time_Tracking__c WHERE DreamTeam_Task__c ='{!DFDT_Task__c.Id}' order by CreatedDate asc limit 1");//soql query statement
if (actEnd.getBoolean("done") && actEnd.size!=0) { //if done and at least one result
var results= actEnd.getArray("records"); //get an array of records
url += "&00N70000002FTtR="+results[0].CreatedDate; //append Actual End Time

Any help is appreciated.

Scott
Greg HGreg H

You'll need to create a function to format the date correctly and then pass the formatted date back to the URL variable. If you assign your CreatedDate from the returned query to a variable (String) and then use the substr() function to get the parts you need you could reformat from there.

Code:
var year = val.substr(0,4); //get year from string
var month = val.substr(5,2); //get month from string
var day = val.substr(8,2); //get day from string
etc...

Good luck,
-greg