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
    }
    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);
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        576 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        553 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X