rails postgres ERROR: invalid input syntax for type double precision

ntonnelier

i'm trying the following:

user_calendars.where("extract(day from time_from) = ? ", next_day)

But i keep getting this Error:

PG::InvalidTextRepresentation: ERROR:  invalid input syntax for type double precision: "Saturday" LINE 1: ..."user_id" = $1 AND (extract(day from time_from) = 'Saturday'...

Not sure why it points out type double.

Mike Sherrill 'Cat Recall'

In PostgreSQL, the expression extract(day from time_from) returns a number of type double, representing the day of the month. Saturday is clearly not a valid double.

If you need the argument to where() to match the string 'Saturday' (to match the day of the week), then use the to_char() function.

user_calendars.where("trim(to_char(time_from, 'Day')) = ? ", next_day)

You need trim(), because this kind of call to to_char() is padded to 9 characters.

Case is significant for the argument 'Day'. If you key it as 'day', the returned value won't match 'Saturday'. Instead, an expression like to_char(time_from, 'day') will return something like 'saturday'.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

rails postgres ERROR: invalid input syntax for type double precision

From Dev

Invalid input syntax for type double precision

From Dev

How to solve invalid input syntax for type double precision

From Dev

PostgreSQL - Error: "invalid input syntax for type bytea"

From Dev

'Invalid input syntax for type inet' db error in Django app with postgres and Gunicorn+Nginx as reverse proxy

From Dev

Postgres COPY FROM Fails With invalid input syntax for type timestamp

From Dev

Postgres varchar column giving error "invalid input syntax for integer"

From Dev

Rails Migration - PG::Error: ERROR: invalid input syntax for integer: ""

From Dev

ActiveRecord::StatementInvalid (PG::InvalidDatetimeFormat: ERROR: invalid input syntax for type date: ""

From Dev

Invalid input syntax for type interval

From Dev

Invalid Input Syntax for Type Date

From Dev

Error: invalid input syntax for integer: ""

From Dev

Error: invalid input syntax for integer: ""

From Dev

Python: Error Importing data from CSV to Postgres (ERROR: invalid input syntax for integer:)

From Dev

Trouble with 'double precision' in Postgres

From Dev

"invalid input syntax for type numeric" for entering "emptyness"

From Dev

Error: argument of HAVING must be type boolean, not type double precision

From Dev

Django compress error: Invalid input of type: 'CacheKey'

From Dev

Invalid input syntax for type date: "\N" in postgresql when fetching data

From Dev

pg nodejs package results in 'invalid input syntax for type json'

From Dev

Astyanax Cassandra Double type precision

From Dev

Astyanax Cassandra Double type precision

From Dev

double/float type precision in Python

From Dev

PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "M"

From Dev

ActiveRecord::Enum - PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer:

From Dev

postgres - operator does not exist: double precision ~~ unknown

From Dev

postgres query not matching negative double precision values

From Dev

UNION ALL, cast NULL as double precision, Postgres

From Dev

Jasper not returning proper precision of double Postgres column

Related Related

  1. 1

    rails postgres ERROR: invalid input syntax for type double precision

  2. 2

    Invalid input syntax for type double precision

  3. 3

    How to solve invalid input syntax for type double precision

  4. 4

    PostgreSQL - Error: "invalid input syntax for type bytea"

  5. 5

    'Invalid input syntax for type inet' db error in Django app with postgres and Gunicorn+Nginx as reverse proxy

  6. 6

    Postgres COPY FROM Fails With invalid input syntax for type timestamp

  7. 7

    Postgres varchar column giving error "invalid input syntax for integer"

  8. 8

    Rails Migration - PG::Error: ERROR: invalid input syntax for integer: ""

  9. 9

    ActiveRecord::StatementInvalid (PG::InvalidDatetimeFormat: ERROR: invalid input syntax for type date: ""

  10. 10

    Invalid input syntax for type interval

  11. 11

    Invalid Input Syntax for Type Date

  12. 12

    Error: invalid input syntax for integer: ""

  13. 13

    Error: invalid input syntax for integer: ""

  14. 14

    Python: Error Importing data from CSV to Postgres (ERROR: invalid input syntax for integer:)

  15. 15

    Trouble with 'double precision' in Postgres

  16. 16

    "invalid input syntax for type numeric" for entering "emptyness"

  17. 17

    Error: argument of HAVING must be type boolean, not type double precision

  18. 18

    Django compress error: Invalid input of type: 'CacheKey'

  19. 19

    Invalid input syntax for type date: "\N" in postgresql when fetching data

  20. 20

    pg nodejs package results in 'invalid input syntax for type json'

  21. 21

    Astyanax Cassandra Double type precision

  22. 22

    Astyanax Cassandra Double type precision

  23. 23

    double/float type precision in Python

  24. 24

    PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "M"

  25. 25

    ActiveRecord::Enum - PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer:

  26. 26

    postgres - operator does not exist: double precision ~~ unknown

  27. 27

    postgres query not matching negative double precision values

  28. 28

    UNION ALL, cast NULL as double precision, Postgres

  29. 29

    Jasper not returning proper precision of double Postgres column

HotTag

Archive