|
-
May 21st, 2007, 08:24 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] [2005] How to display Date and/or Time ?
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 ?
-
May 21st, 2007, 08:28 AM
#2
Fanatic Member
Re: [2005] How to display Date and/or Time ?
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?
-
May 21st, 2007, 11:45 AM
#3
Thread Starter
Hyperactive Member
Re: [2005] How to display Date and/or Time ?
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.
-
May 21st, 2007, 06:53 PM
#4
Re: [2005] How to display Date and/or Time ?
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.
vb.net Code:
myDateTimeString = CDate(myDataRow("StartTime")).ToString("d/MM/yy, HH:mm")
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.
-
May 22nd, 2007, 02:29 AM
#5
Thread Starter
Hyperactive Member
Re: [2005] How to display Date and/or Time ?
Thank You for the suggestion Mr.JM but in our country we use dd/mm/yy only !
-
May 22nd, 2007, 02:47 AM
#6
Re: [2005] How to display Date and/or Time ?
 Originally Posted by LuxCoder
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.
-
May 22nd, 2007, 12:03 PM
#7
Thread Starter
Hyperactive Member
Re: [RESOLVED] [2005] How to display Date and/or Time ?
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 !
-
May 22nd, 2007, 05:56 PM
#8
Re: [RESOLVED] [2005] How to display Date and/or Time ?
Thank you for the vote of confidence but my time is fully committed at the moment.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|