Click here to Skip to main content
14,920,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there any way to insert date time in this format "MMMM/yyyy/d ddd hh:mm:ss tt" into sql server 2008 while I insert I use this format, but after I inserted it was in the format "yyyy.mm.dd"

Can anyone help me?
Posted
Updated 16-Jul-13 3:33am
v3

Actually, a DateTime value is always stored the same way in the Sql database, it just a matter of the way it is presented/formatted when you see it in the Sql Manager or read it using a query...

Depends on what you want to do, but just read it into a DateTime variable and format it to string the way you want:

http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^]
   
v4
You can make your column type in sql as datetime , also if you need to insert a new format of date in database make it as varchar(20) and insert the format that you need.
   
Comments
Johnny J. 16-Jul-13 9:59am
   
Sorry, but I have to downvote that... You should never store a date in a varchar variable. That makes for all kinds of problems.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900