Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
5 replies Latest Post - ‏2012-09-27T04:32:53Z by SystemAdmin
rmadhuu88
rmadhuu88
10 Posts
ACCEPTED ANSWER

Pinned topic Date filter in my script

‏2012-09-26T10:23:53Z |
I want to add a date filter in my script.
I want only items who's last modified date is greater than (current date-10 days)
How can I perform this function?
Can Anyone help me with syntax?
Thanks
Madhumathi
Updated on 2012-09-27T04:32:53Z at 2012-09-27T04:32:53Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    648 Posts
    ACCEPTED ANSWER

    Re: Date filter in my script

    ‏2012-09-26T10:58:47Z  in response to rmadhuu88
    var date = getDateTimeInUserTimeZone();
    date = date.addDate("DAY",-10);
    var modifyDate = .....
    if(date.isDateAfter(stDate))
    {

    }
    • SystemAdmin
      SystemAdmin
      648 Posts
      ACCEPTED ANSWER

      Re: Date filter in my script

      ‏2012-09-26T11:00:21Z  in response to SystemAdmin
      Sorry, this code is correct

      var date = getDateTimeInUserTimeZone();
      date = date.addDate("DAY",-10);
      var modifyDate = .....
      if(modifyDate.isDateAfter(date))
      {
      your code here
      }
  • babinag
    babinag
    91 Posts
    ACCEPTED ANSWER

    Re: Date filter in my script

    ‏2012-09-26T11:57:02Z  in response to rmadhuu88
    Or with JavaAPI
    
    ... Item itemByPrimaryKey = catalog.getItemByPrimaryKey(
    "123"); 
    
    long tenDays = TimeUnit.MILLISECONDS.convert(10L, TimeUnit.DAYS); 
    
    long nowMinusTenDays = 
    
    new Date().getTime() - tenDays; 
    
    if (itemByPrimaryKey.getLastModifiedTimeMillis()>nowMinusTenDays) 
    { ...logic... 
    } ...