This code gets the data from the table to show in a table for the user

using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Web; 
    using System.Web.Security; 
    using System.Collections; 
    using System.Collections.Generic;
    using System.Text;

    namespace Form 
    {
        public class RelUse
        {
            public DateTime Date { get; set; }
        }
        public RelUse()
        {
            atribuiValores(row);
        }
        public RelUse(DataRow row)
        {
            assignValues(row);
        }
        protected void assignValues(DataRow row)
        {
            this.Date = Convert.ToDateTime(row["Date"]);
        }
    }    

It gets the date how it is in the database yyyy-mm-dd hh:mm:ss. Can I do some method in the DateTime to change the formatting of the date to dd/mm/yyyy hh:mm:ss

Hi

When outputting the value of the DateTime you can use the ToString method and pass a format string. For example:

Console.WriteLine(Date.ToString("dd/MM/yyyy hh:mm:ss"));

HTH

I put:

using System; 
    using System.Data; 
    using System.Configuration; 
    using System.Web; 
    using System.Web.Security; 
    using System.Collections; 
    using System.Collections.Generic;
    using System.Text;
    namespace Form 
    {
        public class RelUse
        {
            public DateTime Date { get; set; }
        }
        public RelUse()
        {
            atribuiValores(row);
        }
        public RelUse(DataRow row)
        {
            assignValues(row);
        }
        protected void assignValues(DataRow row)
        {
            this.Date = Convert.ToDateTime(row["Date"]);
            Date.toString("dd/MM/yyyy hh:mm:ss")
        }
    } 

And nothing has changed

Hi

Nothing will change until you actually use the Date. So for example, if you want to display the date in a control then you would use the code that I posted.

Can you provide some more info on what it is you want to do with the Date.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.