Creates a column object representing an Date datatype.
New-DateColumn [-Name] <String> [-Sparse] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-DateColumn [-Name] <String> -NotNull [-Default <String>] [-Description <String>] [<CommonParameters>]
Use this function in the Column script block for Add-Table:
Add-Table 'Members' {
Date 'Birthday'
}
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Name | String | The column's name. |
true | false | |
| NotNull | SwitchParameter | Don't allow |
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 |
Add-Table 'Members' { New-DateColumn 'Birthday' -NotNull }
Demonstrates how to create a required date column.
Add-Table 'Members' { Date 'Birthday' -Sparse }
Demonstrate show to create a nullable, sparse date column when adding a new table.
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.
Add-Table 'Members' { Date 'Birthday' -Description 'The members birthday.' }
Demonstrates how to create an optional date column with a description.