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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Date into VarChar Field.

Author  Topic 

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2011-03-03 : 11:02:44
Hi

I am trying to insert a date into a table with a varchar data type so it will show in a format of 03/03/2010, however when inserting the value it is displayed as Mar 3 2011. I know I could change the field type to DateTime but other non datetime values will be entered into this field also.

An example of the code being used is below:

UPDATE a
SET
a.ConfiguredValue = CONVERT(VARCHAR(8),GETDATE(),112)

FROM dbo.SSIS_Configurations a
WHERE ConfigurationID = 2

Anyone have any ideas?

Thanks

chtummala
Starting Member

4 Posts

Posted - 2011-03-03 : 12:55:07
use cast() function

chandu
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-03-03 : 13:07:19
Do you simply need to change the parameters to the convert function or is there a different issue?
SELECT CONVERT(VARCHAR(10),GETDATE(), 101)
Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2011-03-04 : 03:16:50
Hi Guys

Still no luck!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-03-04 : 06:36:00
quote:
Originally posted by rcr69er

Hi Guys

Still no luck!



Did you buy the lottery ?

You have 2 suggestion. If it is not working for you, you need to tell us what is not working, why it didn't work for you.

Explain what do you want with some sample data and required result.

Else you will probably have better luck buying lottery


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

rcr69er
Constraint Violating Yak Guru

327 Posts

Posted - 2011-03-04 : 09:30:13
Thanks for the sarcastic reply.

Got the answer of another website, where the replys are not as rude/stupid when someone makes a mistake. Sorry to you other guys, but thanks for the help.
Go to Top of Page
   

- Advertisement -