I have Textbox1 on my form which is bound to a recordset and in which i want to display Date and/or Time in a custom format.
How do i do this if i want the textbox1 to show this: 31/12/07, 22:50 ?
Printable View
I have Textbox1 on my form which is bound to a recordset and in which i want to display Date and/or Time in a custom format.
How do i do this if i want the textbox1 to show this: 31/12/07, 22:50 ?
How is the value stored in the database? as a date or as a string?
Do you retrieve the time and the date in the columns or in different columns?
value is stored from the datetimepicker control as date in the database. I want to retrieve them to one column but it would be great if you tell me how to do it in different colums.
You should use a DateTimePicker on your form if you want the user to be able to edit the value. If you jut want to display the value then you can use the ToString method of the DateTime type, e.g.Just note that it is generally a bad idea to force a specific date/time format on the user without a very good reason. The user sets their preferred date/time format in Windows Regional Settings and you should do them the courtesy of using those settings. That way every user will see the date and time in the format that they expect. There can be no ambiguity that way. For instance, if you show the user the date as "1/02/07" then an American would assume that that is January 2, while you actually mean February 1. If a user has told Windows that they want things a certain way then you should respect that unless you have a very good reason to do otherwise, and then make sure that the user is aware of your decision so that they don't make incorrect assumptions about the values they are seeing.vb.net Code:
myDateTimeString = CDate(myDataRow("StartTime")).ToString("d/MM/yy, HH:mm")
Thank You for the suggestion Mr.JM but in our country we use dd/mm/yy only !
That's irrelevant. In my country (Australia) we use dd/MM/yyyy as standard but that should make no difference. If your application ends up overseas or someone from overseas uses it in your country and wants to set up their machine to use the regional settings they're used to they should be able to. If I travel to the US I'm going to leave the regional settings on my laptop set to Australian. I'd be p*ssed off if some local software uses US date formats without telling me and I end up doing something or going somewhere on the wrong date. You should respect the choices made by each user, particularly if it doesn't take any more effort on your part to do so.Quote:
Originally Posted by LuxCoder
hmm thats true !
Mr. JM, do you make projects on freelance basis also ? If you do then will you make my project in return of some fees ! I am so much impressed by your replies to my questions in this site, that i completely trust you for that purpose !
Thank you for the vote of confidence but my time is fully committed at the moment.