|
|
I have an app that logs data and serialises a CTime to an archive
ie
<br />
CTime time<br />
<br />
achive << time<br />
I cannot for the life of me get .NET to read it from the file.
I can get the same value from the file , its just that the code below
produces a date somewhere in the 1600's
DateTime time=DataTime.FromBinary(theFileValue);
I can load the value in a C++ MFC program and get the correct result
HELP!!!! Thanks
.Netter
|
|
|
|
|
did you try to provide an IFormatProvider? This is an option which you can define how it's formatted.
|
|
|
|
|
its not the format , the date is totally incorrect, infact the date it reports is 12:01:53 AM on 1/1/0001.
Ive tried all the .From options, none work.
|
|
|
|
|
and Convert.ToDateTime() you can provide as good as everything, maybe that will help
|
|
|
|
|
in fact it just throws and invalid cast exception (as the documentation says)
|
|
|
|
|
Then i think you can use the same solution as i've just given down here:
string strDate = "20060502";
DateTime dtDate = DateTime.ParseExact( strDate, "yyyyMMdd", CultureInfo.InvariantCulture );
strDate = dtDate.ToString();
Where y stands vor years
M for months
d for days
h for hours
m for minutes
s for seconds
Should this work?
|
|
|
|
|
The value is saved in the file as an int32, not a string, the problem is that the .net datetime doesnt interpret this value the same way MFC does with CTime.
|
|
|
|
|
You say the value is saved in the file as an int32. Is it the same as time_t (which is 32 bits)? If so, the C# DateTime is obtained as follows, where the variable "timet" contains your 32 bit time_t value:
DateTime.FromFileTime(10000000 * (long)timet + 116444736000000000)
|
|
|
|
|
i can't check it at the moment but that sounds about right. So thank you very much.
Where did you fid that strange bit of information. Can't think I would have come up with that.
|
|
|
|
|
>> Where did you find that strange bit of information
It is not so strange if you analyze it. Those aren't "magical" numbers in that equation:
DateTime.FromFileTime(10000000 * (long)timet + 116444736000000000)
You can see from the method name that the quantity in parentheses is a FileTime. You already know that time_t is seconds since 1/1/1970. A FileTime is a long representing 100 nanosecond intervals since 1/1/1601. So all you need to do is multiply the time_t by 1e7 to get 100 nanosecond intervals, and then add the number of 100 nanosecond intervals between 1/1/1601 and 1/1/1970, which is easily calculated. Perfectly logical, no? Hahaha.
|
|
|
|
|
Went to work , tested and thats it.Thank you
|
|
|
|
|
how do i fill my dataset with a parameter.
i use a access database.
I use the following select command:
WHERE T075_BORGTOCHTNUMMER_1 LIKE ?
and this code i use to fill my dataset:
<br />
this.dBANBM_T075_BORGTOCHTTableAdapter.FillBy1(this.testdb1DataSet.DBANBM_T075_BORGTOCHT, textBox1.Text.ToString);<br />
The value that's in my textbox on the form is called VAL.
this VAL i put in a string.
the error he returns is:
No overload for method 'FillBy1' takes '1' arguments
I really have no idee to do this.
|
|
|
|
|
Hii,
In ASP.Net Application how can i show tool tip...
Aur any other alternative...
Thanx & Regards
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
|
|
|
|
|
|
I have read the artical but there is no property given in this custom control where i can give tool tip text...
Thanx
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
|
|
|
|
|
From the front end just add <foo title="my tooltip text" >.
Code behind: control.Attributes["title"] = "my tooltip text";
Look at NiceTitle.js to make it prettier
|
|
|
|
|
Thanx for your reply...But the way u wrote it's not Working...my side.
-- modified at 7:55 Friday 12th May, 2006
|
|
|
|
|
Hi
In an XML file, I am getting date as YYYYMMDD and time as HHMMSS.
How can I convert this date to DD-MM-YYYY or DD/MM/YYYY
and time as HH:MM:SS
Thanks for the response
|
|
|
|
|
r u reading the xml file with dataset object...
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
|
|
|
|
|
Convert.ToDateTime( ) function will help you out
|
|
|
|
|
I am reading it like:
<br />
XmlNode date= document.SelectSingleNode("Response/Date");<br />
string newDate = Convert.TodateTime(date.InnerText).toString(); <br />
But at run time, I get ths error:
"String was not recognized as a valid DateTime. "
The value of the xml element is: 20060502
regrds
|
|
|
|
|
huh, why would you first convert it to a DateTime object and then again to a string?
But okay you get an error and we'll solve it!
Okay indead, when you should have 2006-05-02 then the previous solution should work, but you don't have that! So the next solution is:
string strDate = "20060502";
DateTime dtDate = DateTime.ParseExact( strDate, "yyyyMMdd", CultureInfo.InvariantCulture );
strDate = dtDate.ToString();
Greetings,
KrIstOfK
|
|
|
|
|
Thanks KrIstOfK . Your solution worked perfectly well.
I am just curious whats the difference between 'YYYYMMDD' and 'yyyyMMdd'
Similarly, if I have time=091200:
why does hhMMss return '09:00' and HHmmss return '09:12'
thanks
|
|
|
|
|