Date Format Change to dd/mm/yyyy

10 pts.
Tags:
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

Answer Wiki

Thanks. We'll let you know when a new response is added.

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>.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • carlosdl
    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.
    69,240 pointsBadges:
    report
  • Meandyou
    Or if DB2 the SQL would be SELECT your_date, CHAR(your_date,ISO)
    5,220 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following