Solved

Date Time Problem

Posted on 2004-10-14
11
221 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
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.

743 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

12 Experts available now in Live!

Get 1:1 Help Now