Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Number of Days between two dates?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Number of Days between two dates?

    Hey guys,

    What I want to have is an "int" value (in # of days) that is derived from the current date and a future date, which happens to be the expiration date of a futures contract.

    I can pull the Expiration Date out (Instrument.Expiry), and I can pull the current date (Using, DateTime.Now) but I personally cannot convert those to an int, double etc that I need to do some math with it.

    Thanks in advance for the help.

    #2
    Ah the joys..

    only took a few more hours to find out someone made it easy.. ToDay();

    Done and working.

    Comment


      #3
      Wait a minute guys. That only works for front month? It will not give me the numbers of days between now and expiration of a contract that is beyond the current month, so now I am back to the drawing board unless I want to try and do some convoluted figuring with the integers which is not the way to go.

      So I'm back to my original problem - counting the number of day between 'now' and expiration of any contract. Sorry about jumping the gun.

      Here's an example: Current date using ToDay() function is: 20130511. The Expiry date is 20130621 so the integer value subtracting one from the other is 111. Well that's correct, but clearly not what I want.

      Comment


        #4
        Ah .DayOfYear fits the bill.

        Excellent conversation with myself as I trip through this mess.

        Comment


          #5
          http://stackoverflow.com/questions/1...eft-difference


          Originally posted by Steve R View Post
          Wait a minute guys. That only works for front month? It will not give me the numbers of days between now and expiration of a contract that is beyond the current month, so now I am back to the drawing board unless I want to try and do some convoluted figuring with the integers which is not the way to go.

          So I'm back to my original problem - counting the number of day between 'now' and expiration of any contract. Sorry about jumping the gun.

          Here's an example: Current date using ToDay() function is: 20130511. The Expiry date is 20130621 so the integer value subtracting one from the other is 111. Well that's correct, but clearly not what I want.

          Comment


            #6
            yeah i'm sure the answer is in that mess somewhere, but I gotta tell ya I'm glad I tripped over the 2 simple lines that gave me the integer with pretty much zero fuss. Thx.

            Comment


              #7
              Actually bro, I took the time to slave over your link and made a much better product in the end. Just want to let you know.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Mongo, Today, 11:05 AM
              2 responses
              7 views
              0 likes
              Last Post Mongo
              by Mongo
               
              Started by guillembm, Today, 11:25 AM
              0 responses
              3 views
              0 likes
              Last Post guillembm  
              Started by Tim-c, Today, 10:58 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by traderqz, Yesterday, 09:06 AM
              4 responses
              27 views
              0 likes
              Last Post traderqz  
              Started by traderqz, Today, 12:06 AM
              4 responses
              8 views
              0 likes
              Last Post traderqz  
              Working...
              X