Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 7 of 7

Thread: javascript doSelect with date/time

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    6

    Default javascript doSelect with date/time

    Hi

    How should a doSelect query be formatted if you wanted to select incidents which is older than a certain date?

    table: probsummary
    query: flag=true and open.time<'2007/05/05 00:00:00'

    javascript:
    //Initialize file variable
    //table: probsummary
    var filevar=newSCFile( "probsummary" );
    // Select using query: flag=true and open.time<'2007/05/05 00:00:00'
    var imselectvar =filevar.doSelect( help required here);

    Thanks in advance
    Andreas

  2. #2
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    Try this

    filevar.doSelect( "flag=true and open.time<'2007/05/05 00:00:00' ");
    Last edited by tommy; 2007-08-02 at 17:31.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  3. #3
    Junior Member
    Join Date
    Aug 2007
    Posts
    6

    Default works

    Hi,

    It worked fine, thanks!

    //Andreas

  4. #4

    Default

    I'm trying to do this same thing with SC 6.2 and all I get is SQL syntax errors.

    Code:
     
     24300( 16032) 04/07/2008 09:35:47   JS I SCL.abdel.log: Running the following query on "SCLabsencedelegationevents":>>>>> start_date<'04/07/08 09:24:47'
     24300( 16032) 04/07/2008 09:35:47  RTE E start_date<'04/07/08 09:24:47' (script.execute,exec.statements)
     24300( 16032) 04/07/2008 09:35:47  RTE E Invalid syntax for query.  Failed parsing (script.execute,exec.statements)
     24300( 16032) 04/07/2008 09:35:47  RAD I -1
     24300( 16032) 04/07/2008 09:35:47   JS I -1
    (The '-1' is the returned result of the doSelect, ie: it failed)

    I've tried all sorts of date formats (2008/04/07 00:00:00, 08/04/07 00:00:00, 04/07/2008, etc...) and nothing seems to be working.

    My JS is:

    Code:
    eventSelectQuery ="start_date<'04/07/08 09:24:47'";
    print("SCL.abdel.log: Running the following query on \"SCLabsencedelegationevents\":>>>>> "+ eventSelectQuery);
    selectResult =event.doSelect(eventSelectQuery);
    Is there a particular date format I ought to use, or is something else wrong? Thanks a lot.

  5. #5
    Administrator tommy's Avatar
    Join Date
    Nov 2001
    Location
    Copenhagen
    Posts
    4,272

    Default

    Try replacing the "_" with ".". You should not replace dots with underscore inside strings that are passed as arguments. Its only when you need to reference the field in the javascript you need to do that.
    Best regards Tommy
    Blog - - ITIL certified - Accredited Integration Specialist – HP OpenView Service Management

    Want to keep this site alive? Consider making a donation. Click here.

  6. #6

    Default

    That fixes it. Thanks for the tip!

  7. #7
    Member krisman's Avatar
    Join Date
    Mar 2008
    Location
    Regina, SK CANADA
    Posts
    89

    Default

    Hi tommy. I was just having a similar problem. Thanks for the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts