tags:

views:

72

answers:

6

suppose i want the particular format of date of birth as (mm-dd-yyyy)

A: 

For SQL Server

SQL Server Date Formats

Pranay Rana
A: 

Assuming your RDBMS is SQL Server, you can do the following:

SELECT CONVERT(VARCHAR(10), [DateOfBirth], 110) 

There's more information about date formatting here.

LittleBobbyTables
A: 

SQL Server

SELECT convert(varchar, getdate(), 110)

SELECT convert(varchar, DateOfBirth, 110) FROM YourTable

How to format datetime & date in Sql Server 2005

Muhammad Kashif Nadeem
A: 

If you're using Oracle:

select to_char(your_date_column,'MM-DD-YYYY') from your_date_table;
RC
A: 

Use CONVERT function if it is SQL SERVER

Select CONVERT(VARCHAR(10),Birthdate,110) from YourTable

Anil
+3  A: 

Although some people have listed the proper syntax for this in multiple RDBMSs (you really need to indicate which one you're using), I'd like to point out that formatting your data is typically something that should be done by the front end of your application. That's not to say that there's never a reason to do formatting in SQL, but usually it's best to just pass it as a date/time to the front end and let the front end handle how it will represent it to the user. Hopefully, you understand the difference between a date/time and a string.

Tom H.