Formatting Dates in a Data Grid

Comments

2 comments

  • Avatar
    Lucas Drege

    I will pass this to dev team, because the resulting column is returning the result in datetime datatype, while the result should be of string format. In the meantime, try using CONVERT instead of FORMAT function which ensures the result will be string instead of a datetime datatype.

    Since the result is in datetime data type, we render in the ISO format, it is the standard that we follow in eForm, any value of datetime datatype will be displayed in ISO format.

     

    Syntax:

    CONVERT(VARCHAR(10), ‘Datetime value’, 110)

     

    Example:

    SELECT

    CONVERT(VARCHAR(10), th.PREndDate, 110)

    , CONVERT(VARCHAR(10), th.PostDate, 110)
    FROM ....

    0
    Comment actions Permalink
  • Avatar
    Loren Bratzler

    Lucas - Thanks for the tip.  Using a SQL CONVERT function does work.  Interesting thing to note here:

    I wanted my dates to be in MM/dd/yyyy format (with slashes).  You would normally do that in a CONVERT function with date type 101 like this:

    CONVERT(varchar(10),th.PREndDate,101)

    However, when I tried that, I still got the ISO format in the output.  I had to use the date type 110 (as you showed in your example) which returns the date with dashes:  MM-dd-yyyy.

    Not a big deal.  We can live with the dashes but it does make me wonder how AgilePoint is deciding when to convert the output to ISO format.

     

    One other quick questions about the Data Grid:

    I noticed that there is an option in the Configure tab named "DateTime Conversion".  Do you know what this does?  It is not shown in the documentation for the Data Grid control.  I tried checking it but it did not seem to make any difference in how things behaved.

    0
    Comment actions Permalink

Please sign in to leave a comment.