PgSqlTimeStamp Formatting

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
JORGEMAL
Posts: 171
Joined: Thu 03 Jul 2008 23:55

PgSqlTimeStamp Formatting

Post by JORGEMAL » Tue 18 May 2010 23:14

I wonder if this is a question for you.

I have a PgSqlTimeStamp value that is assigned to a textbox control but I want to format it so it appears as dd/mm/yyyy hh:mm:ss.
The time portion should display AM/PM.

I have used the following code but I am sure there must be a better option:
txtFechaReg.Text = SeccEspMedia.FechaReg.Day.ToString() + "/" +
SeccEspMedia.FechaReg.Month.ToString() + "/" + SeccEspMedia.FechaReg.Year.ToString() + " " +
SeccEspMedia.FechaReg.Hour.ToString() + ":" + SeccEspMedia.FechaReg.Minute.ToString() + ":" +
SeccEspMedia.FechaReg.Second.ToString();

Respectfully,
Jorge Maldonado

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 20 May 2010 23:22

Current format is defined basing on the regional settings of your operating system. But you can set the necessary format of the date/time representation using the PgSqlTimeStamp.ToString(format) overload. Description of the PostgreSQL to_char function is here .

Post Reply