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

  • Home
  • SEARCH
  • 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 6680877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:31:34+00:00 2026-05-26T04:31:34+00:00

I am trying to convert a datetime that is returning back from a soap

  • 0

I am trying to convert a datetime that is returning back from a soap service which looks like this: “2011-09-30T11:25:56-05:00”.

I want to parse it to this format “2011-09-30 11:25:56”

When I hard code the datestring in my ruby code, it works:

def parse_date(datestring)
    formattedDateTime = DateTime.strptime("2011-09-30T11:25:56-05:00", "%Y-%m-%dT%I:%M:%S%z")
    dt = formattedDateTime.strftime("%Y-%m-%d %H:%M:%S")

    return dt
end

This example works when I hard code the datestring in. However, the below example will not work. The datestring that it is using is “2011-09-30T11:25:56-05:00”, which is the exact same as I am hardcoding in the above example.

def parse_date(datestring)
    formattedDateTime = DateTime.strptime(datestring, "%Y-%m-%dT%I:%M:%S%z")
    dt = formattedDateTime.strftime("%Y-%m-%d %H:%M:%S")

    return dt
end

This way it throws this error:
[01:29:06 PM 2011-10-09] SourceAdapter raised query exception: private method `sub!’ called for #

Can anyone please let me know what is going on?

  • 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-26T04:31:35+00:00Added an answer on May 26, 2026 at 4:31 am

    I figured out the issue. I had to call to_s because the date that I was trying to parse was really not a string.

    def parse_date(dateobject)
    
        tempdatestring = dateobject.to_s
    
        formattedDateTime = DateTime.strptime(tempdatestring, "%Y-%m-%dT%H:%M:%S%z")
        dt = formattedDateTime.strftime("%Y-%m-%d %H:%M:%S")
    
        return dt
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a little snippet that I'm trying execute: >>> from datetime import * >>>
I am basically trying to convert a string similar to this one: 2011-11-9 18:24:12.3
I have a datetime column in SQL Server that gives me data like this
I'm trying to create a string from the DateTime object which yields the format
I'm trying to convert JSON to C# object using Json.NET. The object looks like
I'm trying to convert a Linq query to SQL. My Linq query looks like
I am trying to write a function that will convert a DateTime.Now instance to
I am trying to convert all DateTime values in a DataTable to strings. Here
I am trying to convert an access datetime field to a mysdl format, using
How can I convert a string 08:00 to a DateTime datatype? Im trying to

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.