Solved

Date Time Problem

Posted on 2004-10-14
11
222 Views
Last Modified: 2010-04-24
if i use the following code to populate a bound textbox and when i write back to the table i get the date not the time

editTimeOut.Text = (Format(Now, "HH:mm:ss"))

Dave
0
Comment
Question by:daverichardson
  • 5
  • 5
11 Comments
 
LVL 10

Expert Comment

by:123654789987
ID: 12306996
I don't think that u will able to write only time values to a datetime field in the database.

If u are using Oracle database u can try to insert the value by

TO_DATE(Now,'HH:MI:SS')

else

if u are using SqlServer u can use
CONVERT (datetime, '14-OCT-2004')
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12307129
With SQL server, there are no type that contains the time only. You have to include a date with it and ignore that date.
0
 

Author Comment

by:daverichardson
ID: 12307137
i am using vb.net

i no it sounds strange but it is just the time i want to write back

Dave
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12307203
The language is not a factor. The database is. Even VB.Net is not supporting a Time DataType.
0
 

Author Comment

by:daverichardson
ID: 12307496
Ok so if i insert the date aswell i get

14/10/2004  00:00:00

The Time is only displayed as 00
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:daverichardson
ID: 12307545
Sorry i ment to say the time is not written properly in the table, but it is displayed ok on the form
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12307546
Try to bind a DateTimePicker (having the Format property set to Time) instead of a textbox.
0
 

Author Comment

by:daverichardson
ID: 12307910
the datetime picker also dosent work
any more ideas what could be causing it

Dave
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 12307946
Why? Even the format is set to time, the Value always contains the date and time!
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 50 total points
ID: 12307962
Why don't you bind your field to an invisible control (label or textbox). When the user changes the time, you also modify the invisible control with a valid date and time.
0
 

Author Comment

by:daverichardson
ID: 12309079
Ok I have sorted it,
I used editTimeIn.Text = (Format(Now, "HH:mm:ss")) to fill the textbox

i also changed System.Data.OleDb.OleDbType.dbdate to
System.Data.OleDb.OleDbType.VarWChar

and it saved fine

Dave

I Have split the points
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now