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
Solved

Date Time Problem

Posted on 2004-10-14
11
225 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 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 1 28
get column names from table in vb.net 8 49
vb.net and creating a class 5 20
location of a form 2 25
This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
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 …

856 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