EFileTahi-A Posted January 23, 2005 Posted January 23, 2005 In VB6 I could convert Date to a numeric value resulting in the total days since 1899, I need to do the same thing with c# so that I can store the dateTime in a numeric field to make possible searching an Access DataBase using the Between Keyword... How can I do this? int iDataNumeric = DateTimePicker1.Value. ? Quote
IngisKahn Posted January 23, 2005 Posted January 23, 2005 You need to use a TimeSpan object. When you subtract two DateTime objects they return a TimeSpan obejct. Then you can use TimeSpan.TotalDays. Quote "Who is John Galt?"
EFileTahi-A Posted January 23, 2005 Author Posted January 23, 2005 Could you post me an example? thank you Quote
IngisKahn Posted January 24, 2005 Posted January 24, 2005 [CS]int iDataNumeric = (int)DateTimePicker1.Value.Subtract(new DateTime(1900, 1, 1)).TotalDays;[/CS] Quote "Who is John Galt?"
EFileTahi-A Posted January 24, 2005 Author Posted January 24, 2005 [CS]int iDataNumeric = (int)DateTimePicker1.Value.Subtract(new DateTime(1900' date=' 1, 1)).TotalDays;[/CS'] Thank you very much IngisKahn Quote
Leaders Iceplug Posted January 24, 2005 Leaders Posted January 24, 2005 There's also DTP.Value.ToOADate. That sounds like the kind of date representation that you are using (days since 12/31/1899), however it returns a Date, so you can convert it to a long/int if you need to. :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.