SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 saving date as varchar in the date format
 New Topic  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

3865 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  
 New 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.06 seconds. Powered By: Snitz Forums 2000