10 pts.
 Date Format Change to dd/mm/yyyy
ASP
I have dates in my database as mm/dd/yyyy and i would like to show in my result page as dd/mm/yy format.

 

I am doing in asp and can you please help me to convert this into dd/mm/yyyy format.

Thanks.



Software/Hardware used:
Software
ASKED: August 22, 2009  7:59 AM
UPDATED: August 25, 2009  6:03 PM

Answer Wiki:
Normally you would handle this in the UI not within the database. Since you didn't tell us the database platform, I'll assume Microsoft SQL Server as you are using ASP. If you were going to do it within the database... If the datatype of the column is DATETIME then you can either use the CONVERT function to convert the value into the correct format. You would want to convert into with 103. <pre>SELECT CONVERT(VARCHAR(10), YourColumn, 103) as YourColumn FROM YourTable</pre> You can set the DATEFORMAT option to dmy within your stored procedure. <pre>CREATE PROCEDURE YourProcedure ... AS SET DATEFORMAT dmy SELECT ... GO</pre> You can change the language of the login which your web application is using to log into the database to British English which will switch the date formatting to the British format. The SET DATEFORMAT option is usually the preferred option if you want to make the change within the database. IF you were going to do it within the ASP code use the <a href="http://forums.aspfree.com/sql-development-6/dateformat-dd-mm-yyyy-15148.html">DATEFORMAT function</a>.
Last Wiki Answer Submitted:  August 22, 2009  10:04 am  by  Denny Cherry   64,550 pts.
All Answer Wiki Contributors:  Denny Cherry   64,550 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

The ‘SAP’ tag could have prevented ASP experts to look at your question.

Fortunately you received the answer you were looking for in spite of that.

 63,580 pts.

 

Or if DB2 the SQL would be SELECT your_date, CHAR(your_date,ISO)

 5,205 pts.