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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T12:41:33+00:00 2026-05-21T12:41:33+00:00

I have an SQL view with a field as such: To_char(date, ‘MM-DD-YYYY’) I have

  • 0

I have an SQL view with a field as such:

To_char(date, 'MM-DD-YYYY')

I have a C# object with a DateTime property. The objects are created based on data retrieved from the database being serialized and then being de-serialized into the object. All works well apart from the DateTime field. Depending on the format of the date returned from the DB, I either get an invalid XML error, or the date is set as 01-01-0001

Edit: Additional code as a response to comment.

De-serialize method:

public static object DeSerialize<T>(string data)
    {

       StringReader rdr = new StringReader(data);
       XmlSerializer xmlSerializer = new XmlSerializer(typeof(T));
       var result = (T)xmlSerializer.Deserialize(rdr);
       return result;



    }

Class to be de-serialized:

public class VolumeData
{
    public string name { get; set; }
    public string study { get; set; }
    public string group { get; set; }
    public double volume { get; set; }
    public DateTime date { get; set; }
}

Used as such:

List<VolumeData> volumeDataCollection = (List<VolumeData>)Serializer.DeSerialize<List<VolumeData>>(xmlData);

As I mentioned, I have no issue using these methods de-serializing other objects, or the properties within this class that is not a DateTime.

Thanks.

  • 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-21T12:41:33+00:00Added an answer on May 21, 2026 at 12:41 pm

    This page describes a similar problem: Force XmlSerializer to serialize DateTime as 'YYYY-MM-DD hh:mm:ss'

    You might be able to cheat a little bit and mark your date field with the [System.Xml.Serialization.XmlElementAttribute] listed on that other stackoverflow page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a simple view consisting of 3 tables in SQL. By right
I want to change the date field in my sql view so that the
I have an sql server view which I've recently added a field to the
I have the following fields for my sql view: name | description | date
I have a MS SQL view that I want to make available as a
I currently have this statement in my SQL View (SQL Server 2008 R2) which
I have a ASP.NET MVC 4 project and a SQL View (vvItem). ItemController MVCAppEntities
I have an SQL Server Reporting Services (SSRS) report, that uses a view. That
I have a view in SQL Server 2008 that I want to use for
I have an SSIS package that queries data from a view using an SQL

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.