Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Date Time Problem

Posted on 2004-10-14
11
Medium Priority
?
232 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

604 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