Announcement

Collapse
No announcement yet.

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

    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

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            152 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            89 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            131 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            127 views
            1 like
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            107 views
            0 likes
            Last Post CarlTrading  
            Working...
            X