Click to See Complete Forum and Search --> : Display Date Without the Time
adsc
Feb 10th, 2003, 07:50 AM
I am trying to display the date from SQL server database into a window form textbox as "dd/MM/yyyy", but it shows the time also.
Any idea how to avoide this.
Thanks for the help
dwhawley
Feb 10th, 2003, 08:21 AM
use the formatdatetime() or the format()
for example
textbox1.text = formatdatetime(dteDateandTime, DateFormat.ShortDate)
or
textbox1.text = format(dteDateandTime, "MM/dd/yyyy")
adsc
Feb 10th, 2003, 08:36 AM
Databinding removes the format !!
Me.txtRegDate.DataBindings.Add("Text", myDS.Tables("Member"), "RegDate")
dwhawley
Feb 10th, 2003, 09:26 AM
in cases like this, i have traditionally modified my sql statement to return a string representation of the date i want to look at. the problem with this approach, however, is if you try to sort by that column, its sorted by the string, not the date. i have been looking for a way around this, but still havent found one. sorry.
adsc
Feb 10th, 2003, 09:37 AM
Thank u for your help
adsc
Feb 10th, 2003, 01:05 PM
dwhawley,
This solves the problem perfectly, look at the Format and Parse events.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsbindingclassformattopic.asp
Originally posted by dwhawley
in cases like this, i have traditionally modified my sql statement to return a string representation of the date i want to look at. the problem with this approach, however, is if you try to sort by that column, its sorted by the string, not the date. i have been looking for a way around this, but still havent found one. sorry.
dwhawley
Feb 10th, 2003, 02:48 PM
nice find and thanks for the return message. my issue has been formatting values within a datagrid and it appears that this is how you do it
thanks
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.