ASDATE doesnt convert AM/PM correctly

Answered

Comments

4 comments

  • Official comment
    Alan Mark

    Hi Elwyn,

    I created some test data to figure this out and we needed to account for the milliseconds:

    ASDATE(#date_test!date; 'dd-MMM-yy hh.mm.ss.SSSSSS a')

    Comment actions Permalink
  • Alan Mark

    Hi Elwyn,

    The mistakes here are you are using capital letter 'HH' in your date parse pattern, and you have not indicated an AM/PM marker in your date.  So you're specifying 24 hour time and not informing the parser of the time of day.

    If you use 'hh' it should respect the 12 hour clock, and you'll want to add 'a' to the end of your date pattern as so:

    ASDATE(#MODIFIED_DATE; 'dd-MMM-yy hh.mm.ss a')

    I'd expect the returned output to be: 2019/09/14 5:06:25 PM

    For more information please see our documentation on Date and Time Parse Patterns

    0
    Comment actions Permalink
  • Elwyn Roberts

    Hi Alan,

     

    Unfortunately I tried that in the past and the "a" doesnt seem to work.  See screenshot attached.  MODIFIED_DT is a STRING datatype.  MODIFIED_DT1 has the formula as shown.

    0
    Comment actions Permalink
  • Elwyn Roberts

    Perfect - thanks so much.  Funnily enough in my very first attempts to figure this out I did include the milliseconds, but unbeknownst to me the HH was causing an issue too.

    Great work, thank you so much for all your help.

    0
    Comment actions Permalink

Please sign in to leave a comment.