Hi, when I convert an empty field to date gives 1900-01-01, converting null to date gives null.
I have a SQL View where I transform rows to columns.
Here are my 2 lines:
(SELECT Convert(date,[Value]) FROM ActivityEntryData WHERE ActivityEntryId = A.LastActivityEntryId AND [Key] = 'Created') AS "Created",
(SELECT Convert(date,[Value]) FROM ActivityEntryData WHERE ActivityEntryId = A.LastActivityEntryId AND [Key] = 'Closed') AS "Closed",
I need to use something like this:
SELECT CONVERT(DATE, NULLIF([Value], ''))
NULLIF replaces a value with null if it matches a string, in this case an empty string
Hi,
thanks for your reply.
how do i put this into action?
what is the syntax?
here is a snippet again of my 'Closed' field that needs this action to be performed on:
(SELECT Convert(date,[Value]) FROM ActivityEntryData WHERE ActivityEntryId = A.LastActivityEntryId AND [Key] = 'Closed') AS "Closed",
Hi again,
Ignore what I said earlier, I think I've done it now. I didn't need GETDATE, I needed a NULL:
(SELECT CONVERT(DATE, ISNULL(NULLIF([Value], ''), null)) FROM ActivityEntryData WHERE ActivityEntryId = A.LastActivityEntryId AND [Key] = 'Closed') AS "Closed",