 
 (defn- unix-timestamp->timestamp [_ expr seconds-or-milliseconds]
   "Converts datetime string to a valid timestamp"
-  (kutils/func (format "TRY_CAST('%s' as TIMESTAMP)" seconds-or-milliseconds) [expr]))
+  (case seconds-or-milliseconds
+    :seconds       (kutils/func (format "TRY_CAST('%s' as TIMESTAMP)" seconds-or-milliseconds) [expr])
+    :milliseconds  (recur nil (kx// expr 1000) :seconds)))
 
 (defn- date-trunc [unit expr]
   "date_trunc('interval', timestamp): truncates a timestamp to a given interval"

  [_ korma-form {clause :filter}]
  (k/where korma-form (filter-clause->predicate clause)))

(defn- convert-to-isotime
  "Prints datetime as ISO time"
  [sql-time format]

    :quarter-of-year (extract-integer :quarter expr)
    :year            (extract-integer :year expr)))

(defn- sql-interval [unit amount]
  (format "CURRENT_TIMESTAMP + %d" (* (unit) amount)))

(defn- date-interval [_ unit amount]
  "defines the sql command required for date-interval calculation"
  (case unit
    :quarter  (recur nil :month (kx/* amount 3))
    :year     (k/raw (sql-interval YEAR amount))
    :month    (k/raw (sql-interval MONTH amount))
    :week     (k/raw (sql-interval WEEK amount))
    :day      (k/raw (sql-interval DAY amount))))

(defrecord CrateDriver []
  Named
