1. Community Tip: Please Give Thanks to Those Sharing Their Knowledge.
    If you receive helpful answer on this forum, please show thanks to the poster by clicking "LIKE" link for the answer that you found helpful.
  2. Community Tip: Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING)
    Click the link above to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This notice will disappear after you have made at least 3 posts.

Different results with current_timestamp

Discussion in 'Scripting' started by SourMylk, Mar 28, 2012.

  1. SourMylk

    SourMylk Active Newcomer

    Joined:
    Aug 4, 2011
    Messages:
    10
    Likes Received:
    0
    Hi all,

    These 2 scripts give back different results:

    With timestamp:
    Code:
    select distinct events.node_name, events.status, nodes.platform_name from events, nodes where events.node_name=nodes.node_name and events.status<>'Completed' 
    and events.status<>'Future' and events.scheduled_start>current_timestamp-1 day
    With date:
    Code:
    select distinct events.node_name, events.status, nodes.platform_name from events, nodes where events.node_name=nodes.node_name and events.status<>'Completed' 
    and events.status<>'Future' and events.scheduled_start>'2012-03-28'
    How could I get the timestamp one to work?
    It's like it doesn't go back after midnight.
     
  2.  
  3. moon-buddy

    moon-buddy ADSM.ORG Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,651
    Likes Received:
    321
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    What TSM Sever version are you running?
     
  4. SourMylk

    SourMylk Active Newcomer

    Joined:
    Aug 4, 2011
    Messages:
    10
    Likes Received:
    0
    TSM version 5.5
     
  5. ChrisRees

    ChrisRees ADSM.ORG Senior Member

    Joined:
    Jul 24, 2008
    Messages:
    539
    Likes Received:
    13
    Occupation:
    Storage Management Person
    Location:
    Birmingham, UK
    Hi

    I thnk this will work

    Change the last part to be

    date(events.scheduled_start)>='2012-03-28'

    Cheers
     
  6. SourMylk

    SourMylk Active Newcomer

    Joined:
    Aug 4, 2011
    Messages:
    10
    Likes Received:
    0
    Hi,

    My problem is that I want to use the current_timestamp, so I don't have to rewrite the date every time I want to use the script.
     
  7. ChrisRees

    ChrisRees ADSM.ORG Senior Member

    Joined:
    Jul 24, 2008
    Messages:
    539
    Likes Received:
    13
    Occupation:
    Storage Management Person
    Location:
    Birmingham, UK
    Hi

    try this,

    select distinct events.node_name, events.status, nodes.platform_name from events, nodes where events.node_name=nodes.node_name and events.status<>'Completed' and events.status<>'Future' and events.scheduled_start>='2012-01-01' and scheduled_start >= current_timestamp - 24 hours

    Hope that helps
     
    SourMylk likes this.
  8. SourMylk

    SourMylk Active Newcomer

    Joined:
    Aug 4, 2011
    Messages:
    10
    Likes Received:
    0
    This one works!
    Thank you!
     
  9. SourMylk

    SourMylk Active Newcomer

    Joined:
    Aug 4, 2011
    Messages:
    10
    Likes Received:
    0
    But I don't really understand why this works :D
     

Share This Page