Click here to Skip to main content
16,008,490 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dim A = DateDiff(DateInterval.Minute, datefrom, dateto)
i want convert this code to c# please help me?
Posted

TimeSpan span= dateto-datefrom;
Double A=span.TotalMinutes;
 
Share this answer
 
You can use this code in C#.
C#
DateTime datefrom = DateTime.Now.Subtract(new TimeSpan(1, 0, 0, 0, 0)); // move back time
DateTime dateto = DateTime.Now;

TimeSpan tmp = dateto - datefrom;
long diff = (long)tmp.TotalMinutes;

// or the one liner
long diff = (long)(dateto - datefrom).TotalMinutes;
 
Share this answer
 
dynamic A = DateAndTime.DateDiff(DateInterval.Minute, datefrom, dateto);


Use the below tool.

http://www.developerfusion.com/tools/convert/vb-to-csharp/[^]
 
Share this answer
 
Comments
George Jonsson 30-Oct-14 4:51am    
Looks like a hybrid between vb and c#.

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