473,383 Members | 1,918 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.

convert a C++ CTime to a C# DateTime

Hello,

How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).

Thanks,
--
Chris
Nov 16 '05 #1
2 18787
dear Chris,

The Parse method of DateTime may handle this, take a try(remember to read
the CTime as a string first).

hope it helps.

"Chris" wrote:
Hello,

How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).

Thanks,
--
Chris

Nov 16 '05 #2

"Chris" <bo****@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,

How can i convert a C++ CTime (4 bytes) into a C# DateTime ?
(my CTime is read in a file).


I beleive that CTime has the same storage representation as time_t, which is
a 64 bit integer representing the number of seconds since January 1, 1970
UDT. Marshall it as an Int64, and do the date arithmetic yourself.

Something like
static DateTime CTimeToDate(Int64 CTime)
{
TimeSpan span = TimeSpan.FromTicks(CTime*TimeSpan.TicksPerSecond);
DateTime t = new DateTime(1970,1,1).Add(span);
return TimeZone.CurrentTimeZone.ToLocalTime(t);
}

David
Nov 16 '05 #3

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...
3
by: Vicki Carlsen | last post by:
Hi, What is the easiest way to convert a DateTime object to a long?? - And the other way back?? (For database use) Regards, Vicki
2
by: Thomas Lindroos | last post by:
how to convert this??? string strDate = "19701105"; DateTime myDate = System.Convert.ToDateTime(strDate); ideas anyone /thomas lindroos
2
by: ad | last post by:
I use a textbox for user to enter a date. How can I determine if the string can convert to datetime.
0
by: Harry Haller | last post by:
The context is shown below in the getGames() method. I get errors on these lines: dtGames.Rows = (TimeSpan)dtGames.Rows; dtGames.Rows = (DayOfWeek)dtGames.Rows; because the playDate column...
5
by: Fabio | last post by:
Hi all! A simple question: I need to convert a DateTime var to a byte (or to a Int64). How? Thanks! --
2
by: santoshpayal | last post by:
Hi, I have a text file that contains a date column. The text file will be imported to database in SQL 2000 server. After to be importing, I want to convert the date column to date type. For...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
3
by: AccessHunter | last post by:
Hi, I am trying to input data to a SQL server table from my source Access 2003 table. The table name is Cases. One of the columns 'DateClosed' has datetime as data type in the source database. In...
1
by: NareshN | last post by:
Hi All, I have stringarray called Timesplit with time like(17:00-2:00).How to store Timeplit array values into datetime array value.I am having 7 values that's why i am using TimeIn.I will...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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...

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.