|
|
Is it better work with date/time in same field or separated? |
|
Author |
Message |
Eliana
|
Posted: Thu Dec 18 12:36:33 CST 2003 |
Top |
SQL Server >> Is it better work with date/time in same field or separated?
Hi,
Is it better work with date/time in same field or separated as below:
varX = '12/12/2003' + '12:45' »» in same field in the table
OR
varX = '12/12/2003' + '12:45' »» in separated fields in the table
varY = '12:45'
Thanks,
VILMAR
BRAZIL
PRAIA GRANDE/SP
SQL Server54
|
|
|
|
|
Aaron
|
Posted: Thu Dec 18 12:36:33 CST 2003 |
Top |
SQL Server >> Is it better work with date/time in same field or separated?
Use a DATETIME column. This will make the most out of indexing, date range
queries, date comparisons, built in functions like datepart(), dateadd() and
datediff(), and easier legibility.
Since SQL Server doesn't have separate DATE and TIME datatypes, moving them
to separate columns would either mean (a) having useless date information in
the "time" column and useless time information in the "date" column, or (b)
converting the columns to a different datatype. For more information, see
http://www.aspfaq.com/2206
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
> Hi,
> Is it better work with date/time in same field or separated as below:
> varX = '12/12/2003' + '12:45' »» in same field in the table
> OR
> varX = '12/12/2003' + '12:45' »» in separated fields in the table
> varY = '12:45'
>
> Thanks,
>
> VILMAR
> BRAZIL
> PRAIA GRANDE/SP
>
>
|
|
|
|
|
|
|