logo

Extras - Tech Tip: Dynamic Dates in Westlaw Intranet Links

By Susan Charkes, Published on February 1, 2000

Susan Charkes is the Systems Librarian for Dechert Price & Rhoads in Philadelphia. Ms. Charkes practiced law in New York City for 7 years before becoming involved in the information professions. She has held positions in technology consulting and electronic publishing, as well as in corporate information services for Warner-Lambert Co. and other organizations. She received a BA in English from The University of Chicago, a JD from Columbia University and an MLS from Rutgers, the State University of New Jersey. Ms. Charkes is Director/Web Manager of the Philadelphia Chapter of Special Libraries Association.

Suppose you want to set up an Intranet link to a Westlaw database in order enable researchers to view the most recent documents published during a time period that is a "rolling window". The period of time is fixed, but the start date varies depending on when the search is done. For instance, enable researchers to find only documents published within the last 30 days.

Lexis makes it easy to set up a window, using the "relativedate" search term. For example, "relativedate=previous_30_days". Days, weeks, months and years all may used as parameters. Lexis Intranet Solutions builds this into the form for creating the Research Link.

But if you have worked with Westlaw's Intranet Toolkit you know that there is no built-in Westlaw syntax to accomplish this. And Westlaw's own technical support was stumped by the question.

Nonetheless, it can be done! I created some JavaScript code that implements the window by generating the beginning of the window (the relative date) as a date specific, when the link is clicked. Then this date is used as part of the search statement.

The example used here is a search of the NJADR database for notices, etc., published within the last 30/60/90 days. It is set up as a form, allowing the researcher to select a 30-, 60- or 90-day window.

The code is in two parts. The first part defines the necessary JavaScript functions, which you can incorporate into any page, with a little tweaking. Put this into the <HEAD> section.

<SCRIPT LANGUAGE="JavaScript">

function GetThatDate (numberOfDays) {
today = new Date() ;
var msPerDays = (numberOfDays * 24 * 60 * 60 * 1000) ;
var msOnThatDate = (today.getTime() - msPerDays) ;
var thatDate = new Date (msOnThatDate) ;

var mName = thatDate.getMonth() + 1;
var yName = thatDate.getYear();
var dayNr = ((thatDate.getDate()<10) ? "0" : "")+ thatDate.getDate();

var Year = yName + ((yName < 100) ? 1900 : 0);
if (Year < 999) {Year += 1900; } //fix 2/15/00

if((mName==1) |(mName==2) |(mName==3) |(mName==4) |(mName==5) |(mName==6) |(mName==7) |(mName==8) | (mName==9))
  var Month = ("0" +mName)
else var Month = mName;

// String to display the date.
   var theDate =(+Month+ "%2F" +dayNr+ "%2F" +Year);
return theDate;
}
 

// put date into search string: customize for your search

function dateformHandler() {
var theDate = GetThatDate(document.datesearchForm.datesearch.options[document.datesearchForm.datesearch.selectedIndex].value)
var westURL = ("http://www.westlaw.com/search/default.asp?db=NJ%2DADR&query=pr%28notice+or+%22rule+proposal%22+or+%22final+regulation%22+or+%22proposed+regulation%22%29+and+da%28aft+"+theDate+"%29&Method=TNC&Action=SEARCH&ForceAction=Y&RS=IT2.02&VR=1.0")

window.location.href = westURL;

}

</SCRIPT>

The only part that is not completely portable here is the surrounding search statement in the definition of the variable "westURL". This is everything other than +theDate+ immediately above. You will have to edit this for each search.

The second part of the code is the link itself, which is a form. You will customize the link text  and may also change any of the time periods. Put this form into the <BODY> section.

<FORM name = "datesearchForm">New Jersey Dept. of Environmental Protection Notices published in past&nbsp;<SELECT NAME="datesearch" SIZE=1 ><option VALUE="30">30<option VALUE="60">60<option value="90">90</SELECT> days&nbsp;&nbsp;<input type="button" value="Retrieve" onClick="dateformHandler()"></FORM>

Here is the code used in a form.

Variation:

If you don't need to give researchers a choice, instead want to hard-code in a time period, use the following code instead, which does not use a form; rather it actually generates the initial date every time the page is loaded. (Change the variable numberOfDays to change the window).

In the <HEAD> section:

<SCRIPT LANGUAGE="JavaScript">

function GetThatDate (today) {
var numberOfDays = 30 ;//customizable
var msPerDays = (numberOfDays * 24 * 60 * 60 * 1000) ;
var msOnThatDate = (today.getTime() - msPerDays) ;
var thatDate = new Date (msOnThatDate) ;

var mName = thatDate.getMonth() + 1;
var yName = thatDate.getYear();
var dayNr = ((thatDate.getDate()<10) ? "0" : "")+ thatDate.getDate();
var Year = yName + ((yName < 100) ? 1900 : 0);
if (Year < 999) {Year += 1900; } //fix 2/15/00

if((mName==1) |(mName==2) |(mName==3) |(mName==4) |(mName==5) |(mName==6) |(mName==7) |(mName==8) | (mName==9))
  var Month = ("0" +mName)
else var Month = mName;

// String to display the date.
   var theDate =(+Month+ "%2F" +dayNr+ "%2F" +Year);
return theDate;
}

</SCRIPT>


In the <BODY> section (here, set up to do the NJADR search in a 30-day window - you'll have to customize your search statement by editing the "begin link" and "complete link" strings):

<SCRIPT LANGUAGE="JavaScript">

// NJADR Search
// Begin link

document.write ('<a href="http://www.westlaw.com/search/default.asp?db=NJ%2DADR&query=pr%28notice+or+%22rule+proposal%22+or+%22final+regulation%22+or+%22proposed+regulation%22%29');

// Start date routine
var today=new Date();

// Write date to page.
document.write ('+and+da%28aft+',GetThatDate(today),'%29') ;

// Complete link
document.write ('&Method=TNC&Action=SEARCH&ForceAction=Y&RS=IT2.02&VR=1.0"> NJ-ADR recent notices <\/a>: <br>New Jersey Dept. of Environmental Protection Notices published in past 30 days') ;

</SCRIPT>

Here is a page using this link.

There are probably ways to simplify and make this code even more portable. I'd welcome any suggestions. It has been successfully tested on both Netscape 4.7 and IE 5. If I get around to it before West does, I may put together a form that generates this code.

Many thanks to Genie Tyburski, who asked the question that got me started on this project, and whose testing and comments were essential to the finishing of it.