| | |
dispaly date only in vb.net
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2009
Posts: 3
Reputation:
Solved Threads: 0
Guys please help me out on ths'
I have created a table in sql ' managed to change datetime to date only in (sql query analyzer ' parsed it ) its shown date only n sql table but its shown both datetime in vb.net textbox Please tell me if my method is right or gve me the correct method.
I will be really thankful. U can even e mail me direct on my e mail
sunilgill2007@hotmail.com
I have created a table in sql ' managed to change datetime to date only in (sql query analyzer ' parsed it ) its shown date only n sql table but its shown both datetime in vb.net textbox Please tell me if my method is right or gve me the correct method.
I will be really thankful. U can even e mail me direct on my e mail
sunilgill2007@hotmail.com
Use ToShortDateString of the DateTime class. Here's an example
VB.NET Syntax (Toggle Plain Text)
Dim SQLDateTime As Date Dim OnlyDate As String ' Debug, get this value from SQL Server. Notice: This is my locale date format SQLDateTime = CDate("15.5.2009 15:53:00") OnlyDate = SQLDateTime.ToShortDateString MessageBox.Show(OnlyDate, "Only Date", MessageBoxButtons.OK, MessageBoxIcon.Information)
Teme64 @ Windows Developer Blog
Here's another way to do it If you still can't get the date part only, show the original datetime value read from DB.
VB.NET Syntax (Toggle Plain Text)
Dim SQLDateTime As Date Dim OnlyDate As String Dim TempPos As Integer ' Debug, get this value from SQL Server. Notice: This is my locale date format SQLDateTime = CDate("21.5.2009 10:36:00") ' Locate the space character. That should be a separator between the date and the time parts TempPos = SQLDateTime.ToString.IndexOf(" ") If TempPos >= 0 Then OnlyDate = SQLDateTime.ToString.Substring(0, TempPos) Else OnlyDate = "Invalid date" End If MessageBox.Show(OnlyDate, "Only Date", MessageBoxButtons.OK, MessageBoxIcon.Information)
Teme64 @ Windows Developer Blog
![]() |
Similar Threads
- Want Date Format in dd/mm/yyyy in ASP.Net With C#. (C#)
- sending email from asp.net/sqlserver on a particular date (VB.NET)
- how can add date in vb.net form (VB.NET)
- ProgrammersTalk.net Recruiting Forum Posters (Internet Marketing Job Offers)
- I need someone to go over the "hijackthis" process because of a spyware hit please (Windows 95 / 98 / Me)
Other Threads in the VB.NET Forum
- Previous Thread: Retrieve Contacts from Exchange Public Folder
- Next Thread: Get centerscreen of form1
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account application arithmetic array basic bing button buttons center check code combobox component crystalreport data database datagrid datagridview date design dissertation dissertations dropdownlist excel fade file-dialog filter ftp generatetags google gridview hardcopy hosting images input insert intel internet listview mobile monitor ms net networking objects output panel passingparameters peertopeervideostreaming picturebox picturebox1 port position print printing problem problemwithinstallation project remove save searchbox searchvb.net select serial shutdown soap survey table tcp temperature text textbox timer timespan toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf year





