Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 saving date as varchar in the date format
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

331 Posts

Posted - 02/08/2013 :  12:30:59  Show Profile  Reply with Quote
I have a table Customer where there is a field Customer_date which is of varchar(50) datatype.

I am getting data from another table where the date is of varchartype but when i am doing the transfer the dates are getting store as Feb 25 2013 12:00:00 instead of 02/25/2013...

I am doing the transfer through .cs page of ASP.NET. Can someone give me suuggestions...

thank you in advance

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/08/2013 :  12:43:59  Show Profile  Reply with Quote
If at all there is a choice, you should change the data type of the Customer_date column to DATE or DATETIME. That would be beneficial for a number of reasons.

That aside, if you want to keep it as varchar(50), you can convert teh long format to the mm/dd/yyyy format using this:
CONVERT(VARCHAR(50), CAST( 'Feb 25 2013 12:00:00' AS DATETIME),101)
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/08/2013 :  23:02:49  Show Profile  Reply with Quote
also see

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000