Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8061809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:28:00+00:00 2026-06-05T10:28:00+00:00

System::DateTime ^now = System::DateTime::Now; System::DateTime ^now2 = System::DateTime::Now; System::TimeSpan ^span = now->Subtract(now2); The above

  • 0
System::DateTime ^now = System::DateTime::Now;
System::DateTime ^now2 = System::DateTime::Now;
System::TimeSpan ^span = now->Subtract(now2);

The above code gets the compiler error:

test.cpp(104) : error C2664: 'System::TimeSpan System::DateTime::Subtract(System::DateTime)' : cannot convert parameter 1 from 'System::DateTime ^' to 'System::DateTime'  
1>        No user-defined-conversion operator available, or  
1>        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called  

now and now2 are c++/cli handles, but the method expects the actual object. What is the correct way of invoking the method from c++/cli?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:28:03+00:00Added an answer on June 5, 2026 at 10:28 am

    DateTime and TimeSpan are value types.

    System::DateTime now = System::DateTime::Now; 
    System::DateTime now2 = System::DateTime::Now; 
    System::TimeSpan span = now.Subtract(now2); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question from beginner. Why code <%= System.DateTime.Now.ToLongDateString() %> is not executed in ASP.NET. Could
I have a code: int MonthNow = System.DateTime.Now.Month; int YearNow = System.DateTime.Now.Year; int DayNow
Is there a managed system-level sequential number generator? DateTime.Now.Ticks won't do because the operations
Problems with wiring up datepicker The code for partial view @model System.DateTime @Html.TextBox(, Model.ToString(dd/MM/yy),
while doing LINQ I got this Error. Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'.
I assumed that sending a page out with an expiry (a la)... Response.Cache.SetExpires(System.DateTime.Now.AddSeconds(5)); Response.Cache.SetCacheability(HttpCacheability.Public);
I don't know what is wrong with the following string: Report( + System.DateTime.Now.ToString(dd-MMM-yyyy) +
I have this code: startWeekDate = startWeekDate == null ? DateTimeHelpers.calcMondayDate(DateTime.Now) : DateTimeHelpers.calcMondayDate(startWeekDate.Value); DateTime
In the following program, module Program let condition = System.DateTime.Now.Millisecond % 2 = 0
I have this: Dim myTemp As String myTemp = System.DateTime.Now().ToString(MMMddyyyy_HHmmss) & .pdf System.IO.File.Copy(myFile, c:\

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.