Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2016
    Posts
    18
    Provided Answers: 1

    Unanswered: Error cannot cast type timestamp without time zone to integer

    Hello,

    In my
    postgresql 9.4.12
    I have table with field
    Code:
    	created_on int4 NOT NULL,
    which is actually timestamp of row creation.
    running sql-statement I make :
    Code:
     CAST ( now()::timestamp AS Integer )
    but got error :
    *
    Code:
    cannot cast type timestamp without time zone to integer
    which is the right way ?


    Thanks!

  2. #2
    Join Date
    Nov 2003
    Posts
    2,988
    Provided Answers: 23
    What are you trying to do with that? What is the expected integer value for "2017-07-16 19:42"?
    And why are you storing a "timestamp" as a integer and not as a proper timestamp?
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  3. #3
    Join Date
    Oct 2016
    Posts
    18
    Provided Answers: 1
    I did not create the db, but use it. I hope postgresql has tools to convert now() to timestamp...

  4. #4
    Join Date
    Nov 2003
    Posts
    2,988
    Provided Answers: 23
    I don't understand the question: now() is a timestamp.

    See here: https://www.postgresql.org/docs/curr...-datetime.html
    and here: https://www.postgresql.org/docs/curr...TETIME-CURRENT
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

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