Click here to Skip to main content
16,020,673 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all

I need to have a replacement of DateDiff method in C#..... I have translate some vb code into C# and have an error in DateDiff...

Below is my VB Code

VB
If rs("test_date") > Now() Then
                       sb.Append(DateDiff("d", Now(), rs("test_date")) & " days away")
                   Else


Below is C# code

C#
if (Convert.ToDateTime(rs["test_date"]) > DateTime.Now)
               {
                   sb.Append(DateDiff("d", DateTime.Now, rs["test_date"]) + " days away");
               }


Error:
sb.Append(DateDiff("d", DateTime.Now, rs["test_date"]) + " days away");
error name: The name 'DateDiff' does not exists in current context.

You all are requested to let me have a replacement of this...

Thanks
Posted
Updated 14-Jun-15 19:21pm

1 solution

A solution was given here :
DateDiff Method is C#[^]

and also here :
DateDiff replacement in C# from VB[^]

...?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900