question

Mohan Kumar avatar image
Mohan Kumar asked

Date Time Default Value

Hi We have a table with five columns and one of them is a DateTime column. While inserting rows through a trigger, the value for the datetime column is inserted as '1900-01-01 00:00:000' when the value is NULL. Kindly clarify & suggest fix. Rgds Mohan Kumar VS
datetime
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Kev Riley avatar image
Kev Riley answered
For a datetime to have that value, then it will have been set to `0`. If the field is nullable and you have set it to `null`, then it will return `null`. Check if the table has default constraint.
3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

The datetime column is designed as AllowNull. There is no default constraint.
0 Likes 0 ·
Maybe something in the trigger code is replacing `null` with `0` then? Can you post the code?
0 Likes 0 ·
Thanks... The problem was within the trigger as you mentioned. Thanks again.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.