Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7501401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:31:01+00:00 2026-05-29T20:31:01+00:00

Using the clojure jdbc library with postgresql. I have a table xxx with a

  • 0

Using the clojure jdbc library with postgresql. I have a table “xxx” with a timestamp column “created_at” in postgresql, and I have a string containing a date in the right format. Doing an insert fails:

(require '[clojure.java.jdbc :as sql])

(sql/with-connection *db*
  (sql/insert-record :xxx {:created_at "Thu Feb 09 10:38:01 +0000 2012"}))

Here is the error:

org.postgresql.util.PSQLException: ERROR: column "created_at" 
is of type timestamp with time zone but expression is of type character varying

So I understand that postgres requires a timestamp value, but how do I convert my string representation of the date into something postgres will accept? java.util.Date fails also, and I can’t find any docs on the clojure postgres library.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T20:31:03+00:00Added an answer on May 29, 2026 at 8:31 pm

    You’ll need to pass in a java.sql.Timestamp instance. To parse your string into one using clj-time, a Joda-Time-wrapping library for Clojure, you’d do something along the following lines:

    (require '(clj-time [format :as timef] [coerce :as timec])
    
    (->> "Thu Feb 09 10:38:01 +0000 2012"
         (timef/parse (timef/formatter "EEE MMM dd HH:mm:ss Z yyyy"))
         timec/to-timestamp)
    

    The returned value can then be passed to PostgreSQL via JDBC.

    In case you’re obtaining the date in some other string format and converting it to this one, you could skip the conversion and provide an appropriate formatter for the original representation. There are quite a few available by default in the clj-time.format/formatters map, say (clj-time.format/show-formatters) at the REPL to see a list with examples. Also, clj-time.coerce/from-string tries all default formatters in sequence returning the value of the first succeeding parse (nil if there is none). If you’re obtaining the date as a java.util.Date or a long, see from-date and from-long in the same namespace.

    Use [clj-time "0.3.6"] as the dependency specifier in your project.clj if you decide to use clj-time.

    Alternatively, you could use some other way of parsing your timestamp string into a java.sql.Timestamp; Timestamp itself can parse a different string representation:

    (java.sql.Timestamp/valueOf "2004-10-19 10:23:54")
    

    clj-time is the most sane way of dealing with date and time in Clojure, though, so it’s likely to be worth your while.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm calling the twitter4j library using Clojure like so: (def twitter (. (TwitterFactory.) getInstance))
I am using clojure and hiccup (with noir) and I have this code: (defn
I have a problem with the Enclojure REPL and using clojure modules from it.
I'm working on a game in Clojure using Swing. I have a KeyListener to
I am writing a Clojure class using gen-class . I have a state field
I have recently started out with clojure, and I am using leiningen to create
I have been using Clojure alot recently but I still don't understand what functionality
I am trying to use the JACOB library with Clojure using Clojure Box. I
Using clojure I have a very large amount of data in a sequence and
Using clojure and clojure-sql with postgresql. I am trying to make a bootstrap function,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.