Page 1 of 1

PgSqlTimeStamp Formatting

Posted: Tue 18 May 2010 23:14
by JORGEMAL
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

Posted: Thu 20 May 2010 23:22
by Shalex
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 .