Click here to Skip to main content
15,914,013 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i am getting date in this format "dd-MM-yyyy" . When i send this to sql it is considering like the first value "dd" as month.

example:

I am passing two date inputs,Say for example date1 is '1-1-2011' and date2 is '07-1-2011',When pass this sql, Its is considering as jan to july

suggest me how to format the date value 'dd-MM-yyyy' to 'yyyy-MM-dd'
Posted
Comments
André Kraak 1-Nov-11 8:00am    
Please post the code that retrieves the values from the date pickers?

If you wish to change your question use the Improve Question button.

pass your date in dd-MMM-yyyy format, there will not be any confusion after that.

mark as answer if solves your problem
 
Share this answer
 
v2
Thanks

But the problem here is I cant send the "MMM" format, Why because i have a java script date picker which will return only the format like this "dd-MM-yyyy"

suggest me how to make this work, Thing is i cant change the format of date how it is displaying to the client

it would be great if i get the format like this 'yyyy-MM-dd'. This can be easily understandable to sql
 
Share this answer
 
Comments
André Kraak 1-Nov-11 8:01am    
If you have a question about or comment on a given solution use the "Have a Question or Comment?" option beneath the solution. When using this option the person who gave the solution gets an e-mail message and knows you placed a comment and can respond if he/she wants.

Please move the content of this solution to the solution you are commenting on and remove the solution.
Thank you.
use datecasting function in sql .
 
Share this answer
 
try as follows:
C#
DateTime now = DateTime.Now;
                string s = now.ToString("yyyy-MM-dd");


in place of DateTime.Now u can pass the date that u want to convert.
 
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