Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   help (http://www.programmingforums.org/showthread.php?t=11860)

nascar2000 Nov 12th, 2006 8:07 AM

help
 
hello everybody , i am doing a vb project and needs some help. i currently store the date and time details in access database. i want to retreive the time to a textbox. but when i retreive the time the date also show up. how do i limit to time only

thx.

alphonso Nov 12th, 2006 10:57 AM

Next time, don't put words like "help", "please...", and other words that don't specifically say anything.

What was the object you used to call your MS Access file?

hbe02 Nov 12th, 2006 12:20 PM

show us some code so we can help.. i have posted something about MSAccess and dates before, you should also search the forums b4 posting..
what are you using ? oledbreader..?

nascar2000 Nov 12th, 2006 7:02 PM

reply
 
what i mean is this. i want to extract the time from the date function. that is one question. the other one is when i extract a time from the database it shows wrong time,which is not stored in my database , could anyof you explain to me why?

thx

Samuaijack Nov 12th, 2006 8:09 PM

Quote:

show us some code so we can help
:beard:

alphonso Nov 13th, 2006 3:08 AM

We can take literally hundreds of guesses to your question if you don't have the codes posted ;)

melbolt Nov 13th, 2006 9:13 AM

here's one way to do it

:

  1. Public Class Form1
  2.  
  3.     'make a date variable
  4.     Dim theDate As New DateTime
  5.  
  6.  
  7.     ''' <summary>
  8.     ''' form load handler
  9.     ''' </summary>
  10.     ''' <param name="sender"></param>
  11.     ''' <param name="e"></param>
  12.     ''' <remarks></remarks>
  13.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  14.         'get the date and time and put it in the variable
  15.         theDate = Now
  16.     End Sub
  17.  
  18.  
  19.     ''' <summary>
  20.     ''' button click handler
  21.     ''' </summary>
  22.     ''' <param name="sender"></param>
  23.     ''' <param name="e"></param>
  24.     ''' <remarks></remarks>
  25.     Private Sub btnFullDateTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFullDateTime.Click
  26.         'with date and time
  27.         MsgBox(theDate)
  28.     End Sub
  29.  
  30.     ''' <summary>
  31.     ''' button click handler
  32.     ''' </summary>
  33.     ''' <param name="sender"></param>
  34.     ''' <param name="e"></param>
  35.     ''' <remarks></remarks>
  36.     Private Sub btnTimeWithSeconds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimeWithSeconds.Click
  37.         'get the time portion of theDate and split it on the "." to remove the milliseconds, return the 0 index item of the string array
  38.         MsgBox(theDate.TimeOfDay.ToString.Split(".")(0))
  39.     End Sub
  40.  
  41.  
  42.     ''' <summary>
  43.     ''' button click handler
  44.     ''' </summary>
  45.     ''' <param name="sender"></param>
  46.     ''' <param name="e"></param>
  47.     ''' <remarks></remarks>
  48.     Private Sub btnTimeWithoutSeconds_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTimeWithoutSeconds.Click
  49.         'displays the time with only hours and minutes
  50.         MsgBox(theDate.TimeOfDay.ToString.Split(":")(0) & ":" & theDate.TimeOfDay.ToString.Split(":")(1))
  51.     End Sub
  52. End Class



so as you can see, i basically just handled it like a string and parsed out the part of it i wanted in each case.

one button displays the full date and time

another button displays time only, with seconds

and the third button displays time only, without seconds



I'm not going to code the whole program, I'll leave the retrieval of the datetime object from the MSAccess Database up to you, but here is how you can manipulate it once you've retrieved it to get the value you desire out of it.


cheers :banana:


All times are GMT -5. The time now is 12:55 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC