What are the challenges you face when working across database platforms? Take the survey
Options

Exporting SQL Query results to Excel (Dates)

IanPIanP Posts: 2 New member
Hi there,
I am new here so please forgive me if I am posting in the wrong place.

I have a SQL query that returns some dates depending on a number in another column. If the number is zero then I want it to return 1900-01-01, which we use in our systems as a NULL date.

The query returns the date as 1900-01-01, but if I highlight the results grid and Open in Excel these dates appear in the spreadsheet as a STRING.

The SQL I am using is as follow:-

CONVERT(DATE, CASE
  WHEN ISNULL(m.mrpldays, 0) = 0 THEN 0
  ELSE m.mrpltdate
END) AS [Reschedule Date],

Can anyone throw any light on it?

Answers

Sign In or Register to comment.