Click here to Skip to main content
15,913,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,


I need a solution for date format. My scenario is if user change a date format then through out application date format will be same for all controls which is independent of system culture.

How can i achieve this and this and where i set that format so if user change format then easily reflects the application

And my project supported more than one format i.e. dd/MM/yyyy and mm/dd/yyyy.

please suggest me a link or reference.

Thanks in Advance.
Posted
Updated 6-Jul-11 0:44am
v2
Comments
Syed Salman Raza Zaidi 6-Jul-11 6:20am    
Store your date in string type column(varchar or nvarchar) in database
OriginalGriff 6-Jul-11 6:27am    
That is a very bad idea: always store dates as Date or DateTime format. Otherwise you cannot do searches or filters based on them. In addition, to meet the OP requirements, you would have to store the same data in two different string formats. What happens when a third is addded?

You shouldn't try to change the culture - which controls the date format - it could confuse the user.
But, if you need specific format dates, then use the DateTime.ToString method. There is an explanation of the various formats here: Formatting a DateTime for display - format string description[^]
 
Share this answer
 
Comments
[no name] 7-Jul-11 0:23am    
Good Call OriginalGriff. My 5 for you.
Hi...
You can use ToSTring("dd/MM/yyyy") to change the date format...
store the format into database..
Whenever you want to format the date, you can access the date format from database and if the user entered any date format..You can save that format into database..
 
Share this answer
 
v2
Comments
shefeekcm 7-Jul-11 0:42am    
ToSTring("dd/MM/yyyy",cureentdate)
Hi ,
you can use this to cahnge date format.

String.Format("{0:yyyy/M/dd HH:mm}", date)
regards,
shefeek
 
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