• 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

Working with dates around month end

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

    Working with dates around month end

    I am using a formula

    ToDay(Time[0]) == date-2

    where date is in 20120702 (int) format, it works fine for the month, but for a month end it wont work,

    Is there a simple solution to take a date stored as an int to work around month ends, just to take away 2 days or so?

    Thanks

    Tinkerz

    #2
    Hello Tinkerz,
    If you try the below code then are you getting the correct values.

    Code:
    if (ToDay(Time[0]) == ToDay(new DateTime(2012, 7, 2).AddDays(-2)))
    {
    	//do something
    }
    http://www.ninjatrader.com/support/h...html?today.htm
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      My date time is a list of dates in int format to I am matching them up

      The numbers will be changing all the time, so
      (2012, 7, 2)
      will change to 20120702, how can I make that bit change inline with my date integer?

      Comment


        #4
        Hello tinkerz,
        You have to either use a List of DateTime (List<DateTime>) or you can further custom code it and extract the year, month and day from the integer.

        For example to find the year you can use the below function.

        Code:
        private int IntToYear(int date)
        {
                   return (int)(date / 10000);
        }
        And call it from the code as

        Code:
        int year = IntToYear(20121026);
        http://www.ninjatrader.com/support/h...s_explaine.htm
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Seeker of Alpha, Today, 06:17 PM
        0 responses
        9 views
        0 likes
        Last Post Seeker of Alpha  
        Started by gtheaded, Today, 03:47 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_Tyler  
        Started by TAJTrades, Today, 03:25 PM
        0 responses
        6 views
        0 likes
        Last Post TAJTrades  
        Started by DTSSTS, Today, 01:26 PM
        0 responses
        13 views
        0 likes
        Last Post DTSSTS
        by DTSSTS
         
        Started by RFrosty, Today, 01:20 PM
        0 responses
        26 views
        0 likes
        Last Post RFrosty
        by RFrosty
         
        Working...
        X