New-DateColumn

Creates a column object representing an Date datatype.

Syntax

New-DateColumn [-Name] <String> [-Sparse] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-DateColumn [-Name] <String> -NotNull [-Default <String>] [-Description <String>] [<CommonParameters>]

Description

Use this function in the Column script block for Add-Table:

Add-Table 'Members' {
    Date 'Birthday'
}

ALIASES

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The column's name.

true false
NotNull SwitchParameter

Don't allow NULL values in this column.

true false False
Sparse SwitchParameter

Store nulls as Sparse.

false false False
Default String

A SQL Server expression for the column's default value

false false
Description String

A description of the column.

false false

EXAMPLE 1

Add-Table 'Members' { New-DateColumn 'Birthday' -NotNull }

Demonstrates how to create a required date column.

EXAMPLE 2

Add-Table 'Members' { Date 'Birthday' -Sparse }

Demonstrate show to create a nullable, sparse date column when adding a new table.

EXAMPLE 3

Add-Table 'Members' { Date 'Birthday' -NotNull -Default 'get`date`()' }

Demonstrates how to create a date column with a default value, in this case the current date. (You alwyas use UTC dates, right?) Probably not a great example, setting someone's birthday to the current date. Reasons are left as an exercise for the reader.

EXAMPLE 4

Add-Table 'Members' { Date 'Birthday' -Description 'The members birthday.' }

Demonstrates how to create an optional date column with a description.