4
Contributors
9
Replies
31
Views
4 Years
Discussion Span
Last Post by annaharris
0

is it possible to enter a time value like this TimeSpan.Parse("00:00:00") and a date value like this
DateTime.Parse("0000/00/00")

There some of my columns that i dont want to enter a date into it at time of seeding my database e.g. a column like LastPasswordChangedDate in admin table

At time of creation of an admin user, he does not have a value for that column. I dont know if I should just make the table nullable, so I pass a null value.

0

A DateTime is accepted, but am not sure for the TimeSpan. I think not, because it represents a length of time, not a point in time.

The link was to MySQL, I assume you're using MSSQL.

0

yes I am using Mssql. Well on mssql TimeSpan.Parse("00:00:00") accepts this. I can seed my database with that value.
But the problem is actually DateTime.Parse("0000/00/00") when I try to seed the database, it does not insert a value in the row.

0

Try converting to SqlDateTime, and remember ... SQL Server does not recognize dates prior to 1/1/1753

0

tans. that means I can not enter dates in this format 00/00/0000.
Does sql accept nullable types for date.

0

use this code in ur query
string qry = "insert into table_test(datefield)values(getdate())";

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.