• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 digibob, Today, 01:13 AM
              0 responses
              2 views
              0 likes
              Last Post digibob
              by digibob
               
              Started by kemoleena, Today, 12:31 AM
              0 responses
              5 views
              0 likes
              Last Post kemoleena  
              Started by aligator, 09-18-2019, 12:15 PM
              12 responses
              104 views
              0 likes
              Last Post Lancer
              by Lancer
               
              Started by StevenNelson, Yesterday, 05:45 PM
              0 responses
              7 views
              0 likes
              Last Post StevenNelson  
              Started by calebsandfort, Yesterday, 05:16 PM
              1 response
              7 views
              0 likes
              Last Post calebsandfort  
              Working...
              X