You need to sign in to do that
Don't have an account?
shan876
Calculate Time????
How does one calculate time in Salesforce...
I tried:
that did not work... does anyone know the syntax
I tried:
Code:
<html> <head> <script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script> <script type="text/javascript"> function initpage() { var d = "{!Delivery_Time__c.Actual_Arrival_Time__c}"; var e = "{!Dispatch_Schedule__c.Arrival_Time__c}"; document.getElementById('div_tag').innerHTML = d.getTime() ; } </script> </head> <body bgcolor="#F3F3EC" onload="initpage()";> <font size="2" face="Verdana"> <div id="div_tag">Loading...</div></font> </body> </html>
Hi,
There are 'native' functions to deal with date/time values...
Theoretically - you can just use the following function to get the value into a standard JS date object...
Take a look at http://www.w3schools.com/jsref/jsref_obj_date.asp to see the full use of this object...
Then you can manipulate / calculate to your heart's content using JS date functions
Likewise - to make a JS date into a SOQL-compatible date, use the sforce.internal.dateToString() command, as follows:
oh - you need to 'include' the standard salesforce ajax script for the above... "/soap/ajax/10.0/connection.js"
Hope this helps ;)
Ben
Message Edited by London Ben on 03-19-2008 05:23 AM
wow awesome I will definetly try it that way... but this is what I did(see below) but the issue I have is this is an s-control which displays the difference in time on the screen, now management wants it in the object in the custom field difference... I do not know how to do that... I tried but didn't work... any suggestions???
However, when I tried using your code, the Force.com IDE in Eclipse would not update the object, saying that the Year function required a Date and not a Datetime field (I was passing the Opportunity.LastModifiedDate as the merge field). How do I get around this? I've tried simply setting a date variable to the merge field -
var dateMod = new Date({!Opportunity.LastModifiedDate});
but although this doesn't give an error, the date it sets it to is the 1st of January 1970, which is obviously the default date and it is ignoring my parameter.
Any ideas? It is such a simple problem, all I want to do is test the difference between the current date/time against the LastModifiedDate and if this is less than a day, call the rest of the functions.
Erica
Message Edited by m62Dev on 03-21-2008 08:33 AM