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 8835623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:18:04+00:00 2026-06-14T09:18:04+00:00

In Rails I created a string column called open_time , but then I realized

  • 0

In Rails I created a string column called open_time, but then I realized I should use the datetime type. I did:

change_column :polls, :open_time, :datetime

But it said:

PG::Error: ERROR: column "open_time" cannot be cast to type timestamp without time zone
: ALTER TABLE "polls" ALTER COLUMN "open_time" TYPE timestamp

If I just drop the string column and add new datetime column, I will lose the data stored in the string column. Alternatively, in PostgreSQL I can add a column:

ALTER TABLE polls ADD COLUMN published_time timestamp;

Ant then try to get the data from the string column like:

UPDATE polls SET published_time = strToTimeStamp(open_time);

Are there any functions I can use as strToTimeStamp to convert character varying type to timestamp without time zone?

  • 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-06-14T09:18:05+00:00Added an answer on June 14, 2026 at 9:18 am

    .. are there any functions I can use as strToTimeStamp that can convert
    character varying type to timestamp without time zone type?

    Use to_timestamp() to convert string data to type timestamp and alter the data type of the column in place:

    ALTER TABLE tbl ALTER COLUMN col TYPE timestamp
    USING to_timestamp(col, '<your pattern here>');
    

    See:

    • Alter character field to date
    • Cast varchar type to date
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a rails model by doing script/generate model Customer name:string address:string city:string state:string
Ever since I created this Rails 3.2.3 project to use MiniTest, I have been
I created a simple private messaging app through rails, but I am trying to
If I pass a String into Datetime column while creating new AR object, it
I'm trying to use the suffix column of my class but I keep getting
I created sample rails app and deployed into heroku. Rails version is 3.1.3 Ruby
I just created a new rails app in Rails 3.1.1, and my application layout
I am running rails 3.2 I have created a nested form (requests > tags)
I'd created my first web app using Ruby on Rails. And now, I want
I have created a table in my Ruby on Rails application that I am

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.