Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Converting DateTime Values to customized format

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

    Converting DateTime Values to customized format

    Hi all,

    I have some problems converting some values into a user defined format.

    The code:

    Code:
    Print("Date1: " + ToDay(Time[0]).ToString());
    Print("Date2: " + ToDay(Time[0]).ToString("yyyy-MM-dd"));
    Print("Open: " + Open[0]);
    Print("High: " + High[0]);
    Print("Low: " + Low[0]);
    Print("Close: " + Close[0]);
    Print("Volume: " + Volume[0]);
    The result set:

    Date1: 20120127
    Date2: yyyy-MM-dd
    Open: 1314,75
    High: 1319,25
    Low: 1307
    Close: 1312,75
    Volume: 1730153


    Here my problem: I would like to have the date (as a string) in format: "YYYY-MM-DD" and all the the values with a "." instead of "," as seperator.

    Can anyone please provide some code snippets to me?


    Thanks in advance!

    Knoppers

    #2
    Here it is in all its glory, courtesy of a little Google-Fu.

    Learn to use custom date and time format strings to convert DateTime or DateTimeOffset values into text representations, or to parse strings for dates & times.

    Comment


      #3
      Hello Knoppers,
      Thanks for your post and I am happy to assist you.
      Please try these codes:
      Code:
      Print("Date1: " + Time[0].ToString("yyyy-MM-dd")); 
      Print("Date2: " + Time[0].ToString("yyyy-MM-dd")); 
      Print("Open: " + Open[0].ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US").NumberFormat)); 
      Print("High: " + High[0].ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US").NumberFormat));
      Print("Low: " + Low[0].ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US").NumberFormat));
      Print("Close: " + Close[0].ToString(System.Globalization.CultureInfo.GetCultureInfo("en-US").NumberFormat));
      @koganam thanks for your input.

      Please let me know if I can assist you any further.
      JoydeepNinjaTrader Customer Service

      Comment


        #4
        Hi Joydeep & koganam,

        thanks a lot for your hints and your perfect support!

        Works perfectly...

        Comment


          #5
          Hello Knoppers,
          Glad to know it worked for you.

          Please let me know if I can assist you any further.
          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