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

cannot format date

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

    cannot format date

    i cannot seem to change the format of the string coming from the Time object.
    string myInsertQuery = String.Format("insert into scans_logs (symbol, datetime,message) values ('{0}','{1:u}','{2}')",Instrument.FullName,Time,st r);

    i am expecting a datetime format like

    "2008-03-09 16:05:07Z"

    but i keep getting a dateformat like
    '2009-05-31 22:05:00 PM',

    how do i avoid getting the PM from the dateformat.
    ref:

    #2
    junkone, you can check the DateTime class member methods for conversion options for this - http://msdn.microsoft.com/en-us/libr...rs(VS.80).aspx
    BertrandNinjaTrader Customer Service

    Comment


      #3
      i can easily convert the datetime object to any format i want. i just cannot convert the Time object. I am not sure why?

      Comment


        #4
        Time is a DateTime object, you try formatting it as a String with String.Format
        BertrandNinjaTrader Customer Service

        Comment


          #5
          if you look at post # 1, thats excactly that i am trying and it fails to format correctly.
          when i use a regular DateTime.now , it works. so i am not sure why the Time object is not able to be string formatted.

          Comment


            #6
            I compared both DateTime.Now and Time[0] on my end and they both return a DateTime object as expected.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            53 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            33 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            5 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            19 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            6 views
            0 likes
            Last Post cre8able  
            Working...
            X