dispaly date only in vb.net

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2009
Posts: 3
Reputation: sunil01 is an unknown quantity at this point 
Solved Threads: 0
sunil01 sunil01 is offline Offline
Newbie Poster

dispaly date only in vb.net

 
0
  #1
May 15th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: dispaly date only in vb.net

 
0
  #2
May 15th, 2009
Use ToShortDateString of the DateTime class. Here's an example
  1. Dim SQLDateTime As Date
  2. Dim OnlyDate As String
  3.  
  4. ' Debug, get this value from SQL Server. Notice: This is my locale date format
  5. SQLDateTime = CDate("15.5.2009 15:53:00")
  6. OnlyDate = SQLDateTime.ToShortDateString
  7.  
  8. MessageBox.Show(OnlyDate, "Only Date", MessageBoxButtons.OK, MessageBoxIcon.Information)
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 710
Reputation: Teme64 will become famous soon enough Teme64 will become famous soon enough 
Solved Threads: 114
Teme64's Avatar
Teme64 Teme64 is offline Offline
Master Poster

Re: dispaly date only in vb.net

 
0
  #3
May 21st, 2009
Here's another way to do it
  1. Dim SQLDateTime As Date
  2. Dim OnlyDate As String
  3. Dim TempPos As Integer
  4.  
  5. ' Debug, get this value from SQL Server. Notice: This is my locale date format
  6. SQLDateTime = CDate("21.5.2009 10:36:00")
  7. ' Locate the space character. That should be a separator between the date and the time parts
  8. TempPos = SQLDateTime.ToString.IndexOf(" ")
  9. If TempPos >= 0 Then
  10. OnlyDate = SQLDateTime.ToString.Substring(0, TempPos)
  11. Else
  12. OnlyDate = "Invalid date"
  13. End If
  14.  
  15. MessageBox.Show(OnlyDate, "Only Date", MessageBoxButtons.OK, MessageBoxIcon.Information)
If you still can't get the date part only, show the original datetime value read from DB.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC