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

Please need help in this.

In my application, there is something called user-settings where he can select application settings according to his need.
So i have date format also in that.

So every user can select different different date format.but SQL Server will take only one format.

Now what i want is suppose the user selects the date format as YYYY/DD/MM, in the application it should show the date format in the same way, but while saving in database it should get saved in sql's own format.

Please tell me how to do this..
Posted

The way to do this is to store the date in a consistent manner everywhere internally, and the only place that it should change to something else is when displaying something on the UI or reading it back from user input on the UI.

User preferences should define how something is displayed, not how it is stored internally.
 
Share this answer
 
Comments
[no name] 5-Aug-13 8:10am    
give me some example..
H.Brydon 5-Aug-13 9:15am    
I recommend use of ISO 8601 format (eg. https://en.wikipedia.org/wiki/ISO_8601) or a variation for storage in files, and the native method for storage in memory. On Windows/VB.NET, this should be a DateTime structure (eg. http://msdn.microsoft.com/en-us/library/system.datetime.aspx).

You should have a default display format (eg. ISO 8601) for display in controls, and let the user override that. The user's preference should be honored whenever displaying the date in the UI. The user preference should only be seen in the UI logic. Whenever using or persisting the date in your code, it should be 100% based on the DateTime structure and no connection to the user's UI preference should be seen anywhere in the business layer or data layer.
please see this. maybe helps you.
 
Share this 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