date difference
-
hi.... lets say i have a date an old date... how can i get the difference in date(not the hour and sec and min.) only the date difference between that 2 year old date and currect date?? and get the answer as date? can someone pls help?? tks... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
hi.... lets say i have a date an old date... how can i get the difference in date(not the hour and sec and min.) only the date difference between that 2 year old date and currect date?? and get the answer as date? can someone pls help?? tks... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
I am not sure that I have understood your question correctly, but here is an example how you could get the timedifference between to dates: //Lets say we want the time difference from 2002-02-25 to today. DateTime t2 = DateTime.Now; DateTime t1 = System.Convert.ToDateTime("2002-02-25"); int years = t2.Year - t1.Year; int months = t2.Month - t1.Month; int days = t2.Days = t1.Day; Rickard - Keep Reflecting
-
hi.... lets say i have a date an old date... how can i get the difference in date(not the hour and sec and min.) only the date difference between that 2 year old date and currect date?? and get the answer as date? can someone pls help?? tks... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
TimeSpan diff = DateTime.Now - oldtime; int nDays = diff.Days
You're never going to get anywhere if you can find the answer to such simple questions yourself. -
I am not sure that I have understood your question correctly, but here is an example how you could get the timedifference between to dates: //Lets say we want the time difference from 2002-02-25 to today. DateTime t2 = DateTime.Now; DateTime t1 = System.Convert.ToDateTime("2002-02-25"); int years = t2.Year - t1.Year; int months = t2.Month - t1.Month; int days = t2.Days = t1.Day; Rickard - Keep Reflecting
i was looking for an asnwer that does the calculation for me instead of making me do the subtraction of days and months and years one by one... its quite tedious if i do it that way... i managed to figure out a solution anyway... tks for your effort:) "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
I am not sure that I have understood your question correctly, but here is an example how you could get the timedifference between to dates: //Lets say we want the time difference from 2002-02-25 to today. DateTime t2 = DateTime.Now; DateTime t1 = System.Convert.ToDateTime("2002-02-25"); int years = t2.Year - t1.Year; int months = t2.Month - t1.Month; int days = t2.Days = t1.Day; Rickard - Keep Reflecting
This would give 0 for the days. My reply below would give the correct difference between these dates as 761 days.
-
TimeSpan diff = DateTime.Now - oldtime; int nDays = diff.Days
You're never going to get anywhere if you can find the answer to such simple questions yourself.Mark Nischalke wrote: You're never going to get anywhere if you can find the answer to such simple questions yourself. HEY MARKY!!:mad: did u read my post above??? did YA??!!!!:mad: i found the answer myself... and thru msdn and testing myself FYI!! no internet, no forum!!ok??!!! READ BEFORE U POST!!
dtNow = Date.Today tsStatus = dtNow.Subtract(dtUsed) If tsStatus.Days > (365 * 4) Then status = "Inactive" Else status = "Active" End If
the answer I CAME UP with may not be as efficent as yours or as HI-FI as yours, but i am a beginner.. Mark Nischalke Status Gold. Member No. 16070 Messages Posted (while logged in) 1,177 Articles Submitted 6 Biography I was born, I lived, then went to Hell Location United States Occupation Software development, Software Consulting, Software Components, Web design, Systems engineering, Other, Not applicable so i am VERY VERY HAPPY!!Cause i CAME UP with it.. FYI- Been doin asp.net for 3 weeks, JS for 2 days, VB.NET for 3 weeks!:suss: "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18 -
This would give 0 for the days. My reply below would give the correct difference between these dates as 761 days.
The first thing I was thinking about was your solution but with this solution is rather tricky to get the difference in years, days and months. To get the number of years in difference you have to devide the days with years and then also taking leap years and similar things in consideration.
-
i was looking for an asnwer that does the calculation for me instead of making me do the subtraction of days and months and years one by one... its quite tedious if i do it that way... i managed to figure out a solution anyway... tks for your effort:) "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
Mark Nischalke wrote: You're never going to get anywhere if you can find the answer to such simple questions yourself. HEY MARKY!!:mad: did u read my post above??? did YA??!!!!:mad: i found the answer myself... and thru msdn and testing myself FYI!! no internet, no forum!!ok??!!! READ BEFORE U POST!!
dtNow = Date.Today tsStatus = dtNow.Subtract(dtUsed) If tsStatus.Days > (365 * 4) Then status = "Inactive" Else status = "Active" End If
the answer I CAME UP with may not be as efficent as yours or as HI-FI as yours, but i am a beginner.. Mark Nischalke Status Gold. Member No. 16070 Messages Posted (while logged in) 1,177 Articles Submitted 6 Biography I was born, I lived, then went to Hell Location United States Occupation Software development, Software Consulting, Software Components, Web design, Systems engineering, Other, Not applicable so i am VERY VERY HAPPY!!Cause i CAME UP with it.. FYI- Been doin asp.net for 3 weeks, JS for 2 days, VB.NET for 3 weeks!:suss: "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18 -
This solution is not correct. Don't forget the leap years. Some years are longer then 365 days.
i dont need precision... i just need a ROUGH ROUGH APPROX. 4 years.. thats what i need...thats what i wrote the code to find..:cool: "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18