Solved

Date Time Problem

Posted on 2004-10-14
11
227 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 70

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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 70

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
 

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 70

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 70

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 70

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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