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

Need a Script Please...

Status
Not open for further replies.

jschodde

Technical User
Jan 28, 2001
42
US
I have the following javascript function which I need written in vbscript. Would any of you fine people out there care to help a poor fellow out? I only need to return a date/time value.

Basically I need a "negative date" for sorting purposes. The table that stores this value actually has a field for this value. The key is the "future" date.

Code:
function getNegDatestamp(datestamp) {
      var future = new Date(2200,0,2);
      var delta = future - datestamp;
      
      var days    = Math.floor(delta/86400000);
      var hours   = Math.floor((delta - (days*86400000))/3600000);
      var minutes = Math.floor((delta - (days*86400000) - (hours*3600000))/60000);
      var seconds = Math.floor((delta - (days*86400000) - (hours*3600000) - (minutes*60000) )/1000);
      
      var negdatestamp = new XMLDate( "P"+days+"DT"+hours+"H"+minutes+"M" +seconds+"S");
      return negdatestamp.getDatum();
}
 
Sounds like you are looking for an example of the DateDiff function, but being a java ignoramus I don't follow the example.

Can you provide an example of what you are loking for in English rather than code?

You will find DateDiff info here:
I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
With direct analogy, the first few lines are these.
[tt]
function getNegDatestamp(datestamp)
dim future : future = Dateserial(2200,0,2)*86400000
dim delta : delta=future-datestamp
dim days : days=int(delta/86400000)
dim minutes : minutes=int((delta - (days*86400000) - (hours*3600000))/60000)
dim seconds : seconds=int((delta - (days*86400000) - (hours*3600000) - (minutes*60000) )/1000)
[green]'The rest you have to tell the forum your construction of XMLDate object's construction. It would be xslt2.0 data type. It is up to you to show or not, we aren't otherwise interested in it.
'etc etc[/green]
end function
[/tt]
 
tsuji,
Thanks for the code! I'll try what you've created.
Please ignore the last part because those functions are application-specific:

Code:
var negdatestamp = new XMLDate("P"+days+"DT"+hours+"H"+minutes+"M" +seconds+"S");
return negdatestamp.getDatum();

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top