Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

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
0
daverichardson
Asked:
daverichardson
  • 5
  • 5
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
É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
 
Éric MoreauSenior .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
 
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

Featured Post

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!

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now