473,383 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

DateTime from Database

Hi All

I am having a problem retrieving a Date value from an
Access 2000 database using the OLEDbProvider. Can someone
tell me please how to create a DateTime Object with the
date fro m the Database, I need the database date to
subtract it from another date I have to gain the number
of days that have elapsed. I just cannot seem to get this
DateTime thing correct. The field in my Access Database
is defined as a short date. This is kind of what I
tried :
DateTime EmpShStart =new DateTime();
foreach (DataRow dr in ds911.Tables
["Employees"].Rows)
{
EmpShStart = Convert.ToDateTime(dr.Table.Columns
["ShiftStartDate"]),"d",CultureInfo.CurrentCulture,DateTim
eStyles.NoCurrentDateDefault);
}

but that doesn't work, I have tried numerous
combinations, but all of them throw an exception! any
ideas?

Also Can someone Please direct me to a site or something
that actually explains the DateTime class very well,
becasue I have such problems creating objects of the
Datetimes class. I think it would be helpful if I could
read some material that explains the DateTime class in
simple english so that I can understand it well, so that
in the future I don't have these hassles.

Thanks very much for any help

Kevin
Nov 15 '05 #1
1 5053
Kevin try to change in the insert command parameters, the type of the
parameter assigned to the datetime field to be assigned to a datetime type.
This is a bug of oledb adapters, to generate the parameters for the datetime
type wrong.

Hope this helps
Dan Cimpoiesu
"Kevin" <an*******@discussions.microsoft.com> wrote in message
news:09****************************@phx.gbl...
Hi All

I am having a problem retrieving a Date value from an
Access 2000 database using the OLEDbProvider. Can someone
tell me please how to create a DateTime Object with the
date fro m the Database, I need the database date to
subtract it from another date I have to gain the number
of days that have elapsed. I just cannot seem to get this
DateTime thing correct. The field in my Access Database
is defined as a short date. This is kind of what I
tried :
DateTime EmpShStart =new DateTime();
foreach (DataRow dr in ds911.Tables
["Employees"].Rows)
{
EmpShStart = Convert.ToDateTime(dr.Table.Columns
["ShiftStartDate"]),"d",CultureInfo.CurrentCulture,DateTim
eStyles.NoCurrentDateDefault);
}

but that doesn't work, I have tried numerous
combinations, but all of them throw an exception! any
ideas?

Also Can someone Please direct me to a site or something
that actually explains the DateTime class very well,
becasue I have such problems creating objects of the
Datetimes class. I think it would be helpful if I could
read some material that explains the DateTime class in
simple english so that I can understand it well, so that
in the future I don't have these hassles.

Thanks very much for any help

Kevin

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
1
by: dcrespo | last post by:
Hi to all, I have functions defined in an xml-rpc server. Some functions query to a Postgres database (using adodb) and return its recordset. So, if some xml-rpc client runs the mentioned...
3
by: Matthias S. | last post by:
Hi, I create a DateTime object in C# like this... DateTime _DateStart = new DateTime(2000, 1, 1, 1, 1, 1, 1); Now I save it to the Database (into a DateTime type of column) using the...
9
by: Simon Harvey | last post by:
Hi all, I'm having a bit of a problem working with dates. My computer is british, but I'm developing an american application so I therefore need to use american dates. But I can't get my...
4
by: Mohan | last post by:
In the database, we are storing time in 3 columns: hours, Minutes and AM,PM. After retrieving it from the database, I want to load these values into a DateTime variable. I haven't had much...
29
by: dyork | last post by:
When getting data from a database using the dbapi and an SQL query, how do you in general round trip the data? Especially date-time? An SQL datetime column translates nicely into a Python...
7
by: TheLostLeaf | last post by:
DateTime tTime = DateTime.Now; ------------------------------------------------------------------------------------------- tTime returns "1:59:00 PM" it never returns seconds. Database field...
11
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I have a SQL database table with rows in which the primary key is a DateTime type (although I don't use the Time part). Have added numerous rows and now want to delete one so I enter the date...
4
by: shapper | last post by:
Hello, I have the following: DateTime c = database.Posts.Max(b =b.CreatedAt).Value; b.CreatedAt is of type "DateTime?" The problem is when database.Posts is empty. I get an error:...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.