Topic
  • 5 replies
  • Latest Post - ‏2012-09-27T04:32:53Z by SystemAdmin
rmadhuu88
rmadhuu88
10 Posts

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

    Re: Date filter in my script

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

    }
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Date filter in my script

    ‏2012-09-26T11:00:21Z  
    var date = getDateTimeInUserTimeZone();
    date = date.addDate("DAY",-10);
    var modifyDate = .....
    if(date.isDateAfter(stDate))
    {

    }
    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

    Re: Date filter in my script

    ‏2012-09-26T11:57:02Z  
    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... 
    } ...
    
  • rmadhuu88
    rmadhuu88
    10 Posts

    Re: Date filter in my script

    ‏2012-09-26T13:50:04Z  
    Sorry, this code is correct

    var date = getDateTimeInUserTimeZone();
    date = date.addDate("DAY",-10);
    var modifyDate = .....
    if(modifyDate.isDateAfter(date))
    {
    your code here
    }
    Hi Alex,

    Please find my attachment below. It gives me the same date though I use the code!
    What could be the reason for this?
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Date filter in my script

    ‏2012-09-27T04:32:53Z  
    • rmadhuu88
    • ‏2012-09-26T13:50:04Z
    Hi Alex,

    Please find my attachment below. It gives me the same date though I use the code!
    What could be the reason for this?
    Hi,

    you used a wrong parameter value "DD", the right is "DAY"