0

I need to convert item.MergedDate, which is a date, to a string.

Code as follows

If item.MergeDate.ToString() = "12/31/9999 11:59:59 PM" Then
    item.MergeDate = ""
End If

Obviously this is a terrible attempt, but

I have tried = Nothing and didnt work.

Thank You

Mikey3Strings
  • 109
  • 3
  • 13
  • its answered here http://stackoverflow.com/questions/5869661/why-can-i-not-check-if-datetime-is-nothing [1]: http://stackoverflow.com/questions/5869661/why-can-i-not-check-if-datetime-is-nothing – Binil May 29 '12 at 04:22
  • 1
    What exactly are you trying to do, and what is the end result that you want? – Mark Hall May 29 '12 at 04:38
  • Well im trying to say, if the date is equal to 12/31/9999, for it to appear as a "TEXT" in the list view table. – Mikey3Strings May 29 '12 at 04:41
  • binil, i dont see how that is the answer. MinValue I get a return of 01/01/0001 which is not "TEXT" – Mikey3Strings May 29 '12 at 04:45

2 Answers2

1

Just an extension of SSS idea, but you could add another property to item, MergeDateAsString (Or overload it i suppose)

  Public Property Merge() As String
        Get
            Return _MergeDate
        End Get
        Set(ByVal value As String)
            _MergeDate = value
        End Set
    End Property

    Public ReadOnly Property MergeDateAsString
        Get
            Dim returnValue As String = String.Empty
            If _MergeDate <> Date.MinValue Then
                returnValue = _MergeDate.ToString
            End If
            Return returnValue
        End Get
    End Property

And then bind to the new property instead

spacemonkeys
  • 1,689
  • 5
  • 16
  • 29
0

Change the data type of the Item.MergeDate property to a String

You can't store text in a Date variable.

SSS
  • 4,807
  • 1
  • 23
  • 44