![]() In Half-Open, the beginning is inclusive while the ending is exclusive. I suggest you change your thinking to make a habit of the Half-Open approach to defining span-of-time. LocalDateTime stop = stopDate.atStartOfDay() ![]() ![]() LocalDateTime start = startDate.atStartOfDay() LocalDate stopDate = LocalDate.parse( "" ) LocalDate startDate = LocalDate.parse( "" ) Nevertheless, we should get in the habit of asking java.time to determine the start-of-day. With LocalDateTime, we have no time zone anomalies to account for. To solve the date with time-of-day problem, we need to determine the start of the day. Use a PreparedStatement with placeholders, and pass objects via the `set As of JDBC 4.2 we can exchange java.time objects with the database. You are providing a date-only value but your column holds date-with-time-of-day values.Īnother problem: You are using dumb strings where you should be using smart objects. What type instead of String should I use to store "start_date" and "end_date" and pass them to the query?īTW SELECT COUNT(*) FROM table WHERE activitydate > '' AND activitydate ? AND activitydate ? AND activitydate < ? AND zipcode = ?") įor SQL using Half-Open span-of-time: "SELECT * FROM tbl WHERE when ! '' AND activitydate < '' I tried to use String to pass the date but didn't work( : ERROR: operator does not exist: timestamp without time zone > character varying). The "activitydate" column of "table" in postgresql is "timestamp without time zone". I am trying to run a query in postgresql through Java and JDBC.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |