0

I'm modifying a report that uses SQL Server to export data from package software (Yardi Voyager) into an MS Excel template. The data mostly comes over fine.

However on a few date fields the letter "N" is appended to the imported data and displayed in the cell in Excel. (This is NOT #N/A - just "N")

For example, FORMAT(tbl.dtStart, 'dd/MM/yyyy') returns 31/01/2022 in interactive SQL, which is correct, but the value appearing in the Excel cell is: 31/01/2022N

Same for FORMAT(tbl.dtStart, 'dd/MM/yyyy', 'en-AU')

What I WANT is the usual number of days since 1/1/1900. (And then I'll format it in EXCEL) This value is needed for use in the next step in Excel.

CONVERT(Varchar, tbl.dtStart, 103)

will display 31/01/2022 correctly (no 'N') but is text only - not the number of days needed for the next step in Excel

I expect that this has something to do with how MS handles international characters and uses the prefix 'N' for NVARCHAR. But in all the research I've done I can not figure out how to simply eliminate the 'N' and get the number-date.

I suppose it could be something to do with the package software as well, but that would be strange.

I should also note that I have seen this on at least one text field as well - The letter "N" appended to the text value.

As I mentioned, I am modifying an existing report. The original code used

FORMAT(tbl.dtStart, 'dd/MM/yyyy')

successfully without any N. When I modified those lines the "N" began appearing.

Would greatly appreciate replies on how to export the date-number from SQL Server to Excel without the "N".

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MaybeWeAreAllRobots
  • 1,105
  • 2
  • 9
  • 12
  • 1
    `What I WANT is the usual number of days since 1/1/1900 ... then I'll format it in EXCEL`. Note the Excel has a _quirk_ (not exactly a bug, since it's "by design") where [the number of days is wrong before day 59.](https://stackoverflow.com/a/727495/3043) – Joel Coehoorn Aug 10 '23 at 16:34
  • 1
    Its going to be a quirk of `Yardi Voyager`? Nothing in SQL Server causes that... so probably best to contact product support... – Dale K Aug 10 '23 at 23:56

0 Answers0