473,406 Members | 2,713 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,406 software developers and data experts.

C# and SQL Server DateTime Conversion

Hello,

I'm having some problems right now with something that would seem to be
rather simple (and probably is). But, the solution is escaping me right
now.

Currently, I have created a data structure with a timestamp in it. This is
created in a DLL written in C++. The command that I use to get the
timestamp is:

GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)

At the other end, I have an SQL Server database. Within a table, I have a
column named 'TSTAMP' with a Data Type of 'datetime'.

Between the dll and server, I have a C# application to retrieve the
information from the DLL and add it to the database. However, I'm having
problems figuring out the correct conversion. I know that the 'datetime'
datatype is different from that in .net.

When I retrieve the data from the dll, I execute the following command on
the timestamp:

DateTime.FromFileTime(myEvent.timestamp);

Then, I go to add it to the database but get an error. I've tried casting
it, etc. but to no avail. I also found the SqlDateTime structure but I
don't know how to apply it to DateTime so I can add the data to the
database.

Would you happen to have any suggestions?

Thanks in advance,

Chris
Nov 15 '05 #1
1 14962

"Chris" <c w a n @ n o s p a m - v i g i l . c o m> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
Hello,

I'm having some problems right now with something that would seem to be
rather simple (and probably is). But, the solution is escaping me right
now.

Currently, I have created a data structure with a timestamp in it. This is created in a DLL written in C++. The command that I use to get the
timestamp is:

GetSystemTimeAsFileTime(LPFILETIME lpSystemTimeAsFileTime)

At the other end, I have an SQL Server database. Within a table, I have a
column named 'TSTAMP' with a Data Type of 'datetime'.

Between the dll and server, I have a C# application to retrieve the
information from the DLL and add it to the database. However, I'm having
problems figuring out the correct conversion. I know that the 'datetime'
datatype is different from that in .net.

When I retrieve the data from the dll, I execute the following command on
the timestamp:

DateTime.FromFileTime(myEvent.timestamp);

Then, I go to add it to the database but get an error. I've tried casting
it, etc. but to no avail. I also found the SqlDateTime structure but I
don't know how to apply it to DateTime so I can add the data to the
database.

Would you happen to have any suggestions?

Thanks in advance,

Chris

Nov 15 '05 #2

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

Similar topics

15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
26
by: Reny J Joseph Thuthikattu | last post by:
Hi, I have a variabe in the format of 'DD-MON-YYYY HH:MI AM' .I want to add a miniute to it.How can i do that? by manipulation i want to make '01-JUNE-2004 11:59 PM' to '02-JUNE-2004 12:00 AM'...
1
by: Untitled | last post by:
I have an application that stores all DateTime inforamtion in UTC. However, this application will be accessed from arround the world. I would like my users to be able to specify their prefered...
4
by: Manikandan | last post by:
Hi, I'm inserting a datetime values into sql server 2000 from c# SQL server table details Table name:date_test columnname datatype No int date_t DateTime ...
19
by: RP | last post by:
I have a DateTimePicker with format dd-MM-yyyy. While attempting to insert this date in SQL Server Date column, following exception is thrown: The conversion of a char data type to a datetime...
9
by: Hrvoje Voda | last post by:
How to convert text from textbox "12.05.1977" into "12/05/1977"? and also check if the text is in right format before converting? Hrcko
2
by: Mike | last post by:
Hi, I have DateTime filed in db table. I'd like to search my db based on DateTime filed, actually to list all rows with particular date, for e.g. 16.11.2007... I send string to method for....
1
Manikgisl
by: Manikgisl | last post by:
But the problem is we have dates in Varchar instead Datetime While Converting Varchar To Datetime All four formats are unable to Convert ie select Convert(Datetime,'18-11-2008 2:35:19...
4
by: reach2raziq | last post by:
Hi All, I have one web site and server that is hosted on "Pacific Standard Time" Zone . When a user from different contries creat blogs the displayed time for respective blog will be a server...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.