Datetime to integer conversion and vice versa
-
If i want to convert system date to int , what should i do and also if i try to convert the int to the datetime i should get the same date as before
ItsMe
-
If i want to convert system date to int , what should i do and also if i try to convert the int to the datetime i should get the same date as before
ItsMe
Are you expecting to use a standard int conversion, such as one returned from a C++ API, or do you want to make your own ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
If i want to convert system date to int , what should i do and also if i try to convert the int to the datetime i should get the same date as before
ItsMe
You can not convert DateTime object to Int32 but yes you can convert it to Double using ToOADate() method. To generate DateTime object from Double you can use DateTime.FromOADate() method... For Example
Double d = DateTime.Now.ToOADate(); ... DateTime.FromOADate(d);
Hope this helps you out...M Aamir Maniar aamirOnline.com
-
Are you expecting to use a standard int conversion, such as one returned from a C++ API, or do you want to make your own ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
You can not convert DateTime object to Int32 but yes you can convert it to Double using ToOADate() method. To generate DateTime object from Double you can use DateTime.FromOADate() method... For Example
Double d = DateTime.Now.ToOADate(); ... DateTime.FromOADate(d);
Hope this helps you out...M Aamir Maniar aamirOnline.com
-
any thing is fine but it must work in c# if i give system.datetime.now i must be able to convert to integer and again back to datetime.
Thanks and Regards Madhu
Well, you realisitically need to invent some way of representing it then. Do you need the time, or just the date. An int is 16 bit, so 0x00000000, you could use one byte for month, one for day and two for year. Or, you could set a base date, and store the date as days from that date. There's all sorts of options.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog