473,769 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:

GetSystemTimeAs FileTime(LPFILE TIME lpSystemTimeAsF ileTime)

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.FromFi leTime(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 14975

"Chris" <c w a n @ n o s p a m - v i g i l . c o m> wrote in message
news:O9******** ******@TK2MSFTN GP12.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:

GetSystemTimeAs FileTime(LPFILE TIME lpSystemTimeAsF ileTime)

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.FromFi leTime(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
18894
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 the value in timeonly format by using this command Format(now,"HH:mm:ss") But when I insert it into the Sql Server database, it embadded date value with it. the output looks like that "01/01/1900 08:59:00" in that case time is
26
2688
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' How do i do that? Reny ---
1
1640
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 TimeZone. their timezone. I have written the code to do the timezone conversion. Now what remains is finding a way to make every DateTime display in my application use this code and get converted. I've tried to use the culture info, the...
4
5594
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 C# coding
19
1995
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 data type resulted in an out-of-range datetime value. Please help.
9
451
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
3053
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. eg. 16.11.2007 --short date and convert that to DateTime. After conversion it looks like 16.11.2007 0:00:00 How I can get short date like 16.11.2007 without 0:00:00 after
1
8330
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 PM',102) -- error
4
7889
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 time.. the code below is what i am using for conversion.. TimeZoneInfo PTZone = TimeZoneInfo.FindSystemTimeZoneById( "Pacific Standard Time" ); lbl_createonvalue.Text = TimeZoneInfo.ConvertTime( DateTime.Parse( incident.CreatedOn.ToString() ),...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.