Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hi all

With respect to my previous question Need help in formating datetime as saved in database[^] i wrote the below code to save the user defined date-time format in a variable.

VB
Dim str1 as new SqlCommand("Seelct datetimeformat from test1 where username='a'",con)
con.open()
Dim result as string=str1.executescalar()
datetimepicker1.format=datetimepickerformat.Custom
datetimepicker1.CustomFormat=result

So i am getting the format in "result".

Now i have to convert the date selected using datetimepicker and save it to database.

But the date-time value coming at datetimepicker is link 2013-52-08 (for the format yyyy-mm-dd).why 52 is coming at the place of month..???

please tell me how to do that..
Posted
Updated 5-Aug-13 19:14pm
v3
Comments
Richard MacCutchan 6-Aug-13 3:33am    
Why are you even bothering? This is yet another question that totally misses the point in handling dates. Always (with no exceptions) store dates as Date or DateTime types. The only time it needs to be converted to a readable string is when it is displayed, on screen, webbrowser, printer etc. And at that point you can use the format selected by the user, or default to the system configuration settings.

1 solution

I want to show variable 'result' value.
 
Share this answer
 
Comments
Maciej Los 6-Aug-13 2:30am    
Is it an answer?

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