0

There is one map and one dataset in my account. The dataset is synced to a Google Sheet to which my students add data.

All the layers of the map are derived from the one synced dataset. One of the layers is an animated timeline. The timeline worked fine before syncing, but now that it is synced, the data type of the "date" column is set as "string", and I'm not able to change it.

I found this answer on Stack Exchange, but the solution it refers to is a bit beyond my SQL ability (setting up a dynamic query I could probably manage, but the linked was reference to dates in Postgres is opaque to me at this point.): How do you change the data type of a column for a synced table?

Is there a way to maintain a "date" data format in a synced table?

  • Welcome to GIS SE! As a new user be sure to take the Tour to learn about our focussed Q&A format. – PolyGeo Jan 30 '18 at 23:54
2

You can use the SQL panel of your layer to convert the string into a date column, something like

SELECT *, 
       to_date(my_field, 'DD Mon YYYY') as field_date 
  FROM my_table

Where my_field in this case looks like 05 Dec 2000, for example. You have full documentation on how to_date works at Postgres documentation.

  • can you clarify, if I use the SQL panel to create a date field on my synced data, as shown, will the new field be visible from CARTO-JS or only from within builder? – JMers Sep 12 '18 at 1:10
  • 1
    only from BUILDER, if you want to use CARTO.JS then you write the exact same SQL clause on your JavaScript code. – Jorge Sanz Sep 13 '18 at 7:03
  • please remember to mark the answer as complete when you agree, so we can remove this one from the queue, thanks! – Jorge Sanz Sep 13 '18 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.