Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2010
    Posts
    123

    Unanswered: How to run select statement on column with type timestamp

    Hi all one of my columns type is

    "DATEON" TIMESTAMP NOT NULL WITH DEFAULT CURRENT TIMESTAMP ,


    column content is 10/4/2006 2:34:43 PM


    how to run select statement on this particular column

    and i want to select particular period of time aswell.

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    date(daton)
    time(dateon).. and many other
    see : TIME - IBM DB2 9.7 for Linux, UNIX, and Windows
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  3. #3
    Join Date
    Dec 2010
    Posts
    123
    Thanku for your reply, i got the solun.

    SELECT * FROM TEST WHERE DATE(DATEON)='10-4-2006'

    SELECT * FROM TEST WHERE DATE(DATEON) BETWEEN '10-4-2006' AND '12-4-2008'

  4. #4
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    when specifying dates : always use standard format 'YYYY-MM-DD'
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    Quote Originally Posted by ravichandrapratap View Post
    Thanku for your reply, i got the solun.

    SELECT * FROM TEST WHERE DATE(DATEON)='10-4-2006'

    SELECT * FROM TEST WHERE DATE(DATEON) BETWEEN '10-4-2006' AND '12-4-2008'
    Just so you know, using functions on columns in the WHERE clause will probably use a table scan, even if you have an index on the column.

    Use something like this instead:

    SELECT * FROM TEST WHERE DATEON BETWEEN timestamp('10-4-2006','00:00:00') AND timestamp('12-4-2008','24:00:00')

    Andy

Posting Permissions

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