I'm trying to set a date with value or min value to a VarChar column, but I always get the date format as Jan 1, 2013 instead of the default SQL Server date as "date".
I don't think its possible without engaging in some manic overuse of SUBSTRING etc to get the format '2013-01-07 08:26:00.000' in a varchar field. My personal preference when trying to get the date into a varchar is to use the CONVERT function:
e.g. CONVERT(VARCHAR(8),GETDATE(),112) - this will give the output '20130107'.
Its the third value (the 112) which determines the format of the date. You can have a play around with different values here to get different formats covering the date and time. Without looking it up I think the values run from about 100 to about 115. If you do choose to experiment with these values, don't forget to change the varchar value from 8 characters to something like 20 as most of the others will require more characters.
--------------------------------------------------------------------------------- http://www.mannyroadend.co.uk A Bury FC supporters website and forum
Why does the formation matter when you use SQL? If you want to show dates in formatted way in a front end application, use format function there. If you do not have an option, you can also make use of FORMAT function introduced in version 2012