I’m querying an external API and want to test out data inserts on a test server before moving to production.
Currently, I’m trying to execute the following statement in Postgres’s shell:
CREATE TABLE referrals (client_id VARCHAR(36), device_id VARCHAR(100), conversion_time DATETIME, acquisition_cost MONEY);
but it keeps failing on DATETIME.
Since this doesn’t work, would timestamp? If so, how do I modify timestamp’s default behavior to take in preformatted dates and times?
You don’t have to add
without time zone, that is the default.I use the type
textin the example instead ofvarcharwith a length modifier, because that is usually the better choice. You can usevarchar(n)of course, no problem.locale and
DateStylesettings influence how text input fordate/timestampvalues is interpreted. Use the functionsto_date()orto_timestamp()to be largely independent of local settings:More in the chapter Data Type Formatting Functions of the fine manual.