Date Time Problem

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
daverichardsonAsked:
Who is Participating?
 
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
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
 
123654789987Commented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
daverichardsonAuthor Commented:
i am using vb.net

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

Dave
0
 
Éric MoreauSenior .Net ConsultantCommented:
The language is not a factor. The database is. Even VB.Net is not supporting a Time DataType.
0
 
daverichardsonAuthor Commented:
Ok so if i insert the date aswell i get

14/10/2004  00:00:00

The Time is only displayed as 00
0
 
daverichardsonAuthor Commented:
Sorry i ment to say the time is not written properly in the table, but it is displayed ok on the form
0
 
Éric MoreauSenior .Net ConsultantCommented:
Try to bind a DateTimePicker (having the Format property set to Time) instead of a textbox.
0
 
daverichardsonAuthor Commented:
the datetime picker also dosent work
any more ideas what could be causing it

Dave
0
 
Éric MoreauSenior .Net ConsultantCommented:
Why? Even the format is set to time, the Value always contains the date and time!
0
 
daverichardsonAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.