1. Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING) Click the link 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 message will disappear after you have made at least 12 posts. Thank you for your cooperation.

Different results with current_timestamp

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

  1. SourMylk

    SourMylk New Member

    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 Moderator

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

    SourMylk New Member

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

    ChrisRees Senior Member

    Joined:
    Jul 24, 2008
    Messages:
    537
    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 New Member

    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 Senior Member

    Joined:
    Jul 24, 2008
    Messages:
    537
    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 New Member

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

    SourMylk New Member

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

Share This Page