The column width of date, time, and datetime typed columns in text-only output mode is too narrow. The following query:

  'a' a,
  'aaaaaaaaaaaaaaaaaaaaaaaaaaaa' b,
  getdate() c,
  'a' ddd,
  'aaaaaaaaaaaaaaaaaaaaaaaaaaaa' e,
  3 f,
  3 fff,
  3 g

Produces this text-only output:

a b                            c             ddd e                            f fff g 
- ---------------------------- ------------- --- ---------------------------- - --- - 
a aaaaaaaaaaaaaaaaaaaaaaaaaaaa 2017-06-06 23:42:27a   aaaaaaaaaaaaaaaaaaaaaaaaaaaa 3 3   3 

Note that column c is only given a width of 13 characters when it should be at least 19, and that values in that column butt up against the next column with no whitespace.

1 Answer 1


That is a bug in how the column width for Date types is determined for textonly results.

I have added the following code to the SEDE codebase to resolve the issue.

if (_nativeTypes.Contains(resultSet.Columns[i].Type))
    // Date is formatted later for textresults!
    if (col != null && resultSet.Columns[i].Type == ResultColumnType.Date)
        // col contains a long 
        // for textresults it is formatted later
        // instead of taking its length
        // use the length that will come out after
        // the String.Format is applied
        curLength = DATE_COLUMN_WIDTH; 
        curLength = col?.ToString().Length ?? 4;

When I run this locally, this is my result:

enter image description here

The pull request is here. Allow for 6 to 8 weeks for Nick to merge and re-deploy.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .