Creates a column object representing an DateTime datatype.
New-DateTimeColumn [-Name] <String> [-Sparse] [-Default <String>] [-Description <String>] [<CommonParameters>]
New-DateTimeColumn [-Name] <String> -NotNull [-Default <String>] [-Description <String>] [<CommonParameters>]
Use this function in the Column
script block for Add-Table
:
Add-Table 'Orders' {
DateTime 'OrderedAt'
}
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 'Orers' { DateTime 'OrderedAt' }
Demonstrates how to create an optional datetime
column.
Add-Table 'Orders' { DateTime 'OrderedAt' 5 -NotNull }
Demonstrates how to create a required datetime
column with 5 digits of fractional seconds precision.
Add-Table 'Orders' { DateTime 'OrderedAt' -Sparse }
Demonstrate show to create a nullable, sparse datetime
column when adding a new table.
Add-Table 'Orders' { DateTime 'OrderedAt' -NotNull -Default 'getutcdate()' }
Demonstrates how to create a datetime
column with a default value. You only use UTC dates, right?
Add-Table 'Orders' { DateTime 'OrderedAt' -NotNull -Description 'The time the record was created.' }
Demonstrates how to create a datetime
column with a description.