DateTime contains just Date when added to Dataset/Table

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

Parsing a logfile and adding the data to a database results that my DateTime
field looks good while debugging, but when added through OleDB to a Access
table , just the Date is entered not the whole DateTime.
When adding a records by hand to the table and using VS 2003 a preview
DataSet also only reveals the Date. Porting to VS 2005 Beta a previes does
show Date & Time in dd/mm/yy hh:mm (not hh:mm:ss) format.
Loading a Dataset and showing a DataGrid also only shows the Date while
Date+Time show up while in Access.
Does anybody have a clue what I am missing.

Regards

Ron
 
To get time as well as date then the data stored must be in date time
format. If it is being converted to long integer format at any point then
the time will be lost. Check your data format in each of the scenarios and
make sure there is no point at which the value is being converted to
integer.
 
No problems adding date/time through OLEDB AFAIK. However, if you use
literal date/time values, you need to enclose the value in hashes (#) and the
date/time must be in the format "mm/dd/yyyy hh:nn:ss" (I *think* "mm/dd/yyyy
hh:nn" is OK also).

HTH
Van T. Dinh
MVP (Access)
 
I use the C# DateTime

public DateTime(
int year,
int month,
int day,
int hour,
int minute,
int second
);
That does not leave much to do wrong, I can update my dataset and table
using this class, but for some reason somewhere within the Runtime,
something is deciding that only the date portion of this structure is placed
in the Dataset & table. Do I have to set an application wide Date format or
Culture for the runtime to use the complete DateTime and not just the first
four bytes?
As I said, when I add records by hand then Visual Studio with a preview and
my app also only show the Date.

Regards

Ron
 
If date + time values do show up correctly in Access (as you mentioned in
the last paragraph of your first post), then the updating process is
correct, isn't it?

I would look at the retrieving process and perhaps the formatting of the
DataGrid ... and I think these may be more C# - specific than JET (you are
not using Access!).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top