Share via


ListFieldDateTime Object

SharePoint Designer Developer Reference

Contains information about the field used to display dates and times within a list.

Remarks

The ListFieldDateTime object allows you to view date and time information in a variety of different configurations depending on the type of data in the list. Use ListFields(Index), where Index is the name or ordinal position of a field of type FieldTypeDateTime, to return a single ListFieldDateTime object.

Use the Add method to add a field of type FieldTypeDateTime to the ListFields collection. The following example adds a new field named NewDateTimeField of type FieldTypeDateTime to the ListFields collection.

Visual Basic for Applications
Sub CreateDateTimeField()
'Add new Date/Time field
    Dim objApp As Application
    Dim objLstFlds As ListFields
    Dim strName As String
    Set objApp = Application
    Set objLstFlds = objApp.ActiveWeb.Lists.Item(0).Fields
    strName = "NewDateTimeField"
    'Add new Field of type FieldTypeDateTime to list
    objLstFlds.Add Name:=strName, Description:="New Date Time Field", _
                   Type:=FieldTypeDateTime, Required:=True
    MsgBox "A new Field named " & strName & " was added to the list " & _
           objApp.ActiveWeb.Lists.Item(0).Name & "."
End Sub

See Also