-
Apr 18th, 2008, 03:49 AM
#1
Thread Starter
New Member
how to save time into database when seleced from datetime picker
can someone plz tell me how to save time from datetimepicke in to database...i m using vb.net
-
Apr 18th, 2008, 04:39 AM
#2
Re: how to save time into database when seleced from datetime picker
You'll have a textbox. With the icon next to it which launches the datetimepicker. Datetimepicker writes into textbox. In the codebehind, you read what's in the textbox.
-
Apr 20th, 2008, 07:16 AM
#3
New Member
Re: how to save time into database when seleced from datetime picker
Originally Posted by mendhak
You'll have a textbox. With the icon next to it which launches the datetimepicker. Datetimepicker writes into textbox. In the codebehind, you read what's in the textbox.
what icon that u meant? .. i cant find any icon next to text box .. ..
-
Apr 20th, 2008, 12:44 PM
#4
Re: how to save time into database when seleced from datetime picker
Use any image. People usually use a tiny icon of a calendar. Some even use a link. Look at this example
http://aspnet.4guysfromrolla.com/articles/030202-1.aspx
-
Apr 22nd, 2008, 01:51 AM
#5
Thread Starter
New Member
Re: how to save time into database when seleced from datetime picker
im worlin on window application.....n not on asp.net.....
-
Apr 22nd, 2008, 09:30 AM
#6
Re: how to save time into database when seleced from datetime picker
This is the ASP.NET forum. I'll move your thread.
-
Apr 22nd, 2008, 09:36 AM
#7
Re: how to save time into database when seleced from datetime picker
Do you have a datetimepicker on your form? if not, add one.
Code:
Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
'add your code here
End Sub
-
Apr 22nd, 2008, 09:43 AM
#8
Re: how to save time into database when seleced from datetime picker
The DateTime object contains both the date part and the time part. If you just want the time from the Value of your datetimepicker (wich is a datetime object), you would read the TimeOfDay property of that datetime object (which is a TimeSpan). However, you should save the value as datetime and use only the part that you need.
-
Apr 24th, 2008, 02:17 AM
#9
Thread Starter
New Member
Re: how to save time into database when seleced from datetime picker
can u plz tell me how to retrive only time?im not getting it...plzzzzzzzz
-
Apr 24th, 2008, 02:59 AM
#10
Re: how to save time into database when seleced from datetime picker
Maybe I'm not normal but the extra "z"s don't make me want to help any more than I did. In fact, they make me kind of want to help a little less. They're kind of annoying.
Anyway, exactly what you should do depends on exactly how you want to use the value. If you want to use the value in code then you'd do as stanav already suggested and get a TimeSpan from the TimeOfDay property of your DateTime:
vb.net Code:
Dim myDate As Date 'get this value from database. Dim myTime As TimeSpan = myDate.TimeOfDay
If you want to display the value to the user then you'd simply format the DateTime as a string:
vb.net Code:
Dim myDate As Date 'get this value from database. Dim myTime As String = myDate.ToShortTimeString() MessageBox.Show(myTime) myTime = myDate.ToString("HH:mm") MessageBox.Show(myTime)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|