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
Printable View
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
use the formatdatetime() or the format()
for example
textbox1.text = formatdatetime(dteDateandTime, DateFormat.ShortDate)
or
textbox1.text = format(dteDateandTime, "MM/dd/yyyy")
Databinding removes the format !!
Me.txtRegDate.DataBindings.Add("Text", myDS.Tables("Member"), "RegDate")
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.
Thank u for your help
dwhawley,
This solves the problem perfectly, look at the Format and Parse events.
http://msdn.microsoft.com/library/de...ormattopic.asp
Quote:
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.
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