hi..
i am taking date and time from user as input in different screen.
some times i need only date to be stored and some time only time.
as we have data type datetime in MS SQL Server 2000, it takes both date and time in one field.
so how to take only date or only time from user and store in database.
You should split it into 2 fields... one for date and one for time. If they are only providing a time and not a date sometimes then it should not be split. Don't know why youd wanna do this though|||You can give a datetime field a date, but it will assume you mean midnight on that date.
You can give a datetime field a time, but it will assume you mean 1/1/1900 at that time.
Of course, you can give it both as well.
If you need to know whether a datetime that is exactly midnight is both a date and a time, or just a date, you'll need to either use another field to flag it as such, or know by the field it is in that it always is supposed to be "date-only", or you can store it in a different datatype (varchar).
Same for time.
No comments:
Post a Comment