Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to convert dd/mm/yyyy to sql server default format (yyyy-mm-dd)....?????


I want import data from excel sheet to SQL Server 2008....Here, In my sheet date format is 22/05/2014......So, It throws an Error.............

Conversion failed when converting date and/or time from character string

how to Solve this...............
Posted
Updated 22-May-14 0:33am
v2
Comments
DamithSL 22-May-14 6:41am    
how you import? by code? then update the question with your code
phmani469 22-May-14 7:19am    
i did myself thanks u sir
CONVERT(datetime,'" + g1.Cells[1].Text + "',105)

Try this:

In your Excel Sheet 
1)Select the entire Date  column .
2) Right Click and find Format cells Option.
3) Select the Date Catagory From Format Cells Window.
4) Select The lacale as English(canada).
5 Select your Desire Format and click Ok.
 
Share this answer
 
v2
Comments
phmani469 22-May-14 7:20am    
thanks sir its working....but i did myself like below
CONVERT(datetime,'" + g1.Cells[1].Text + "',105)......thanks for ur another option
I did myself thanks for ur all support
C#
CONVERT(datetime,'" + g1.Cells[1].Text + "',105)
 
Share this answer
 
v2

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