473,883 Members | 1,666 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error converting FILETIME to DateTime

Hi,
it should be simple,
put FILETIME in a Long
conver it in date using the DateTime.FromFi leTimeUtc

The help even says: Converts the specified Windows file time to an
equivalent UTC time.
Now why happens this:
original filetime 21/02/2006 00:33:29

bytes:
80 C2 E6 AB
6D 36 C6 01

when I convert it I have:
1) 20/02/2006 22:26:19
2) 20/02/2006 22:26:19

Code:
Dim ad3 As System.DateTime
Dim aLn1 As Long
Dim ad1 As System.Runtime. InteropServices .ComTypes.FILET IME

ad1.dwHighDateT ime = &H1C6366D
ad1.dwLowDateTi me = &HABE6C280

aLn1 = (CLng(ad1.dwHig hDateTime) << 32) + CLng(ad1.dwLowD ateTime)

ad3 = DateTime.FromFi leTimeUtc(aLn1)
Debug.Print("1) " & ad3)
ad3.ToLocalTime ()
Debug.Print("2) " & ad3)

and even worst if I do:
ad3 = CDate("21/02/2006 00:33:29")

the Thicks property is equal to:
ad3.Ticks &H8C8049591E692 80 Long
please can anyone help me?

Thanks,
M.
Jun 10 '06 #1
14 9491
msAvazzi,

What is it what you want to achieve, there are so many methods in datetime
that I am not seeing what your goal is. I gues that is the same for others.

By instance
http://msdn.microsoft.com/library/de...ssaddtopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:50******** *************** ***********@mic rosoft.com...
Hi,
it should be simple,
put FILETIME in a Long
conver it in date using the DateTime.FromFi leTimeUtc

The help even says: Converts the specified Windows file time to an
equivalent UTC time.
Now why happens this:
original filetime 21/02/2006 00:33:29

bytes:
80 C2 E6 AB
6D 36 C6 01

when I convert it I have:
1) 20/02/2006 22:26:19
2) 20/02/2006 22:26:19

Code:
Dim ad3 As System.DateTime
Dim aLn1 As Long
Dim ad1 As System.Runtime. InteropServices .ComTypes.FILET IME

ad1.dwHighDateT ime = &H1C6366D
ad1.dwLowDateTi me = &HABE6C280

aLn1 = (CLng(ad1.dwHig hDateTime) << 32) + CLng(ad1.dwLowD ateTime)

ad3 = DateTime.FromFi leTimeUtc(aLn1)
Debug.Print("1) " & ad3)
ad3.ToLocalTime ()
Debug.Print("2) " & ad3)

and even worst if I do:
ad3 = CDate("21/02/2006 00:33:29")

the Thicks property is equal to:
ad3.Ticks &H8C8049591E692 80 Long
please can anyone help me?

Thanks,
M.

Jun 11 '06 #2
Cor,
I have a FILETIME (that I read from a File) and I want to store it in a
DateTime variable.

And I do agree with you, it has a lot of methods.

Unluckily it looks like THEY DON'T WORK (or is not clear how to have them
work).
If you try the code I've posted you'll see.

here is tha MSDN reference:
http://msdn.microsoft.com/library/en...asp?frame=true

M

"Cor Ligthert [MVP]" wrote:
msAvazzi,

What is it what you want to achieve, there are so many methods in datetime
that I am not seeing what your goal is. I gues that is the same for others.

By instance
http://msdn.microsoft.com/library/de...ssaddtopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:50******** *************** ***********@mic rosoft.com...
Hi,
it should be simple,
put FILETIME in a Long
conver it in date using the DateTime.FromFi leTimeUtc

The help even says: Converts the specified Windows file time to an
equivalent UTC time.
Now why happens this:
original filetime 21/02/2006 00:33:29

bytes:
80 C2 E6 AB
6D 36 C6 01

when I convert it I have:
1) 20/02/2006 22:26:19
2) 20/02/2006 22:26:19

Code:
Dim ad3 As System.DateTime
Dim aLn1 As Long
Dim ad1 As System.Runtime. InteropServices .ComTypes.FILET IME

ad1.dwHighDateT ime = &H1C6366D
ad1.dwLowDateTi me = &HABE6C280

aLn1 = (CLng(ad1.dwHig hDateTime) << 32) + CLng(ad1.dwLowD ateTime)

ad3 = DateTime.FromFi leTimeUtc(aLn1)
Debug.Print("1) " & ad3)
ad3.ToLocalTime ()
Debug.Print("2) " & ad3)

and even worst if I do:
ad3 = CDate("21/02/2006 00:33:29")

the Thicks property is equal to:
ad3.Ticks &H8C8049591E692 80 Long
please can anyone help me?

Thanks,
M.


Jun 11 '06 #3
And you tried this as well?

http://msdn.microsoft.com/library/de...meUtcTopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:BA******** *************** ***********@mic rosoft.com...
Cor,
I have a FILETIME (that I read from a File) and I want to store it in a
DateTime variable.

And I do agree with you, it has a lot of methods.

Unluckily it looks like THEY DON'T WORK (or is not clear how to have them
work).
If you try the code I've posted you'll see.

here is tha MSDN reference:
http://msdn.microsoft.com/library/en...asp?frame=true

M

"Cor Ligthert [MVP]" wrote:
msAvazzi,

What is it what you want to achieve, there are so many methods in
datetime
that I am not seeing what your goal is. I gues that is the same for
others.

By instance
http://msdn.microsoft.com/library/de...ssaddtopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:50******** *************** ***********@mic rosoft.com...
> Hi,
> it should be simple,
> put FILETIME in a Long
> conver it in date using the DateTime.FromFi leTimeUtc
>
> The help even says: Converts the specified Windows file time to an
> equivalent UTC time.
>
>
> Now why happens this:
> original filetime 21/02/2006 00:33:29
>
> bytes:
> 80 C2 E6 AB
> 6D 36 C6 01
>
> when I convert it I have:
> 1) 20/02/2006 22:26:19
> 2) 20/02/2006 22:26:19
>
> Code:
> Dim ad3 As System.DateTime
> Dim aLn1 As Long
> Dim ad1 As System.Runtime. InteropServices .ComTypes.FILET IME
>
> ad1.dwHighDateT ime = &H1C6366D
> ad1.dwLowDateTi me = &HABE6C280
>
> aLn1 = (CLng(ad1.dwHig hDateTime) << 32) +
> CLng(ad1.dwLowD ateTime)
>
> ad3 = DateTime.FromFi leTimeUtc(aLn1)
> Debug.Print("1) " & ad3)
> ad3.ToLocalTime ()
> Debug.Print("2) " & ad3)
>
> and even worst if I do:
> ad3 = CDate("21/02/2006 00:33:29")
>
> the Thicks property is equal to:
> ad3.Ticks &H8C8049591E692 80 Long
>
>
> please can anyone help me?
>
> Thanks,
> M.


Jun 11 '06 #4
Cor,
If I understood correctly it should be the function I'm using:
ad3 = DateTime.FromFi leTimeUtc(aLn1)
Or I'm doing something wrong?

M

"Cor Ligthert [MVP]" wrote:
And you tried this as well?

http://msdn.microsoft.com/library/de...meUtcTopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:BA******** *************** ***********@mic rosoft.com...
Cor,
I have a FILETIME (that I read from a File) and I want to store it in a
DateTime variable.

And I do agree with you, it has a lot of methods.

Unluckily it looks like THEY DON'T WORK (or is not clear how to have them
work).
If you try the code I've posted you'll see.

here is tha MSDN reference:
http://msdn.microsoft.com/library/en...asp?frame=true

M

"Cor Ligthert [MVP]" wrote:
msAvazzi,

What is it what you want to achieve, there are so many methods in
datetime
that I am not seeing what your goal is. I gues that is the same for
others.

By instance
http://msdn.microsoft.com/library/de...ssaddtopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:50******** *************** ***********@mic rosoft.com...
> Hi,
> it should be simple,
> put FILETIME in a Long
> conver it in date using the DateTime.FromFi leTimeUtc
>
> The help even says: Converts the specified Windows file time to an
> equivalent UTC time.
>
>
> Now why happens this:
> original filetime 21/02/2006 00:33:29
>
> bytes:
> 80 C2 E6 AB
> 6D 36 C6 01
>
> when I convert it I have:
> 1) 20/02/2006 22:26:19
> 2) 20/02/2006 22:26:19
>
> Code:
> Dim ad3 As System.DateTime
> Dim aLn1 As Long
> Dim ad1 As System.Runtime. InteropServices .ComTypes.FILET IME
>
> ad1.dwHighDateT ime = &H1C6366D
> ad1.dwLowDateTi me = &HABE6C280
>
> aLn1 = (CLng(ad1.dwHig hDateTime) << 32) +
> CLng(ad1.dwLowD ateTime)
>
> ad3 = DateTime.FromFi leTimeUtc(aLn1)
> Debug.Print("1) " & ad3)
> ad3.ToLocalTime ()
> Debug.Print("2) " & ad3)
>
> and even worst if I do:
> ad3 = CDate("21/02/2006 00:33:29")
>
> the Thicks property is equal to:
> ad3.Ticks &H8C8049591E692 80 Long
>
>
> please can anyone help me?
>
> Thanks,
> M.


Jun 11 '06 #5
MsAvazzi,

I would ignore that function because it is one of the few functions not used
anymore in the version 2.0

Cor
"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:D2******** *************** ***********@mic rosoft.com...
Cor,
If I understood correctly it should be the function I'm using:
ad3 = DateTime.FromFi leTimeUtc(aLn1)
Or I'm doing something wrong?

M

"Cor Ligthert [MVP]" wrote:
And you tried this as well?

http://msdn.microsoft.com/library/de...meUtcTopic.asp

Cor

"msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
news:BA******** *************** ***********@mic rosoft.com...
> Cor,
> I have a FILETIME (that I read from a File) and I want to store it in a
> DateTime variable.
>
> And I do agree with you, it has a lot of methods.
>
> Unluckily it looks like THEY DON'T WORK (or is not clear how to have
> them
> work).
> If you try the code I've posted you'll see.
>
> here is tha MSDN reference:
> http://msdn.microsoft.com/library/en...asp?frame=true
>
>
>
> M
>
> "Cor Ligthert [MVP]" wrote:
>
>> msAvazzi,
>>
>> What is it what you want to achieve, there are so many methods in
>> datetime
>> that I am not seeing what your goal is. I gues that is the same for
>> others.
>>
>> By instance
>> http://msdn.microsoft.com/library/de...ssaddtopic.asp
>>
>> Cor
>>
>> "msavazzi" <m.*******@disc ussion.microsof t.com> schreef in bericht
>> news:50******** *************** ***********@mic rosoft.com...
>> > Hi,
>> > it should be simple,
>> > put FILETIME in a Long
>> > conver it in date using the DateTime.FromFi leTimeUtc
>> >
>> > The help even says: Converts the specified Windows file time to an
>> > equivalent UTC time.
>> >
>> >
>> > Now why happens this:
>> > original filetime 21/02/2006 00:33:29
>> >
>> > bytes:
>> > 80 C2 E6 AB
>> > 6D 36 C6 01
>> >
>> > when I convert it I have:
>> > 1) 20/02/2006 22:26:19
>> > 2) 20/02/2006 22:26:19
>> >
>> > Code:
>> > Dim ad3 As System.DateTime
>> > Dim aLn1 As Long
>> > Dim ad1 As System.Runtime. InteropServices .ComTypes.FILET IME
>> >
>> > ad1.dwHighDateT ime = &H1C6366D
>> > ad1.dwLowDateTi me = &HABE6C280
>> >
>> > aLn1 = (CLng(ad1.dwHig hDateTime) << 32) +
>> > CLng(ad1.dwLowD ateTime)
>> >
>> > ad3 = DateTime.FromFi leTimeUtc(aLn1)
>> > Debug.Print("1) " & ad3)
>> > ad3.ToLocalTime ()
>> > Debug.Print("2) " & ad3)
>> >
>> > and even worst if I do:
>> > ad3 = CDate("21/02/2006 00:33:29")
>> >
>> > the Thicks property is equal to:
>> > ad3.Ticks &H8C8049591E692 80 Long
>> >
>> >
>> > please can anyone help me?
>> >
>> > Thanks,
>> > M.
>>
>>
>>


Jun 12 '06 #6
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb:
If I understood correctly it should be the function I'm using:
ad3 = DateTime.FromFi leTimeUtc(aLn1)


I would ignore that function because it is one of the few functions not
used anymore in the version 2.0


Why not? I don't see that the method is marked as obsolete:

<URL:http://msdn2.microsoft .com/de-de/library/system.datetime .fromfiletimeut c.aspx>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 12 '06 #7
Herfried,

For this reason I look forever only on the English language website.

http://msdn.microsoft.com/library/de...meUtcTopic.asp

This link was already given by msAvazzi, otherwise I would not have know
this.

Folglich kannst du zur deutschen Seite wieder ein wenig notieren.

Warum du, richtig.
:-)
Cor
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schreef in bericht
news:ud******** ********@TK2MSF TNGP05.phx.gbl. ..
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb:
If I understood correctly it should be the function I'm using:
ad3 = DateTime.FromFi leTimeUtc(aLn1)


I would ignore that function because it is one of the few functions not
used anymore in the version 2.0


Why not? I don't see that the method is marked as obsolete:

<URL:http://msdn2.microsoft .com/de-de/library/system.datetime .fromfiletimeut c.aspx>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 12 '06 #8
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb:
For this reason I look forever only on the English language website.

http://msdn.microsoft.com/library/de...meUtcTopic.asp


Well, that's the documentation of .NET 1.1 and the page simply states that
this member is not supported by .NET *1.0*!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 12 '06 #9
Herfried,

You are right,

It means that the English documentation is not up to date but the German one
is.
I was already disapointed about this breaking change.
:-)

Cor

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schreef in bericht
news:O2******** ******@TK2MSFTN GP02.phx.gbl...
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb:
For this reason I look forever only on the English language website.

http://msdn.microsoft.com/library/de...meUtcTopic.asp


Well, that's the documentation of .NET 1.1 and the page simply states that
this member is not supported by .NET *1.0*!

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jun 12 '06 #10

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

Similar topics

1
38596
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
11
3824
by: jguilford | last post by:
I have created a SQL Stored Procedure that uses a Case statement to determine the Order By. For one of the Case statements I am trying to turn a Char field into Datetime in for the Order By, however I can not get it to work. Can someone please take a look and my code below and tell me what I am doing wrong. Thank you. ORDER BY CASE WHEN @SortBy = 'dttm_stamp' THEN dttm_stamp End, CASE WHEN @SortBy = 'Event_Date1' THEN...
4
25256
by: Saso Zagoranski | last post by:
Hi! I have created an SqlCommand object and I have set some parameters to it... One of the parameters is of the DateTime type; here is the code: sqlCommand.Parameters.Value = DateTime.Parse(this.DateTextBox.Text); sqlCommand.ExecuteNonReader(); I get the error:
5
2557
by: rodri rodri via DotNetMonster.com | last post by:
I have done a program with windows forms in "Visual C++". I have implemented a function that returns two values. For example: double functionExample(int parameter, double __gc* result2); And in a header file, I have written this line: using namespace System::Runtime::InteropServices; This line is necessary for key word. But when compiling the project, I get this error:
1
7262
by: aunthas | last post by:
I want to play sound using winapi, so I wrote these lines of code:- ------------------------------------------------------------------------------------------------------------------- using namespace System; using namespace System::Runtime::InteropServices; namespace WavAPI { extern "C" bool sndPlaySound(String* lpszSound, unsigned int fuSound);
1
4465
by: Andrew Baker | last post by:
this seems to be an SQL Server error but I cant work out how it is occuring. Itr is also after 3am and I cant keep working but need to demo by tomorrow. TIA. The code is: Private Sub myMethod(ByVal cust As String, ByVal invDate As Date) Dim paramDate As New OleDb.OleDbParameter, Dim paramCustomer As New OleDb.OleDbParameter paramDate.ParameterName = "@InvDate" paramDate.Value = invDate
1
3890
by: Sneil | last post by:
I know, general answer for my question is: long hFT2 = (((long) ft.dwHighDateTime) << 32) + ft.dwLowDateTime; DateTime dte = DateTime.FromFileTimeUtc(hFT2); where dwHighDateTime/dwLowDateTime is field of FILETIME structure. But! I call FindFirstFile and receive FILETIME structure with value(for ftLastAccessTime field): High = 29777898 Low = -2072184854
2
2699
by: joyjignesh | last post by:
hi i have make a report with mshflexgrid. the report between two date. when i have written query .open"select * from tablename where t_date>=convert(datetime,' " & text1.text &"') and t2_date>=convert(datetime,' " & text2.text &"'),cn,,,adcmdtext but there is a syntex error to converting datetime format into character string plz help me
1
4677
by: SnehaAgrawal | last post by:
Hi I get the error "Syntax error converting datetime from character string "for the following sql statement in Stored proc. SET @dynamicSQL =N'SELECT CUSTID,SHCodeLink FROM AccountMaster where CONVERT(DATETIME,OPDATE,105) < = '''+CONVERT(DATETIME,@ACCYEAR,105) +''' And GLCode = '+@DIVGLCODE EXEC(@dynamicsql)
0
9940
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9792
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
11141
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
10415
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9573
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7971
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
7126
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
5797
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.