Unix Technical Forum

time data type

This is a discussion on time data type within the SQL Server Data Warehousing forums, part of the Microsoft SQL Server category; --> Hello I have imported some mdb tables to SQL server 2005 Problem is that in access, you could specify ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server Data Warehousing

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:56 PM
=?Utf-8?B?RGF2b3I=?=
 
Posts: n/a
Default time data type

Hello

I have imported some mdb tables to SQL server 2005

Problem is that in access, you could specify date/time data type and use
format to display whatever you like: date or time, or both. But now, in SQL
server, data that was formatted as time is displayed as 30/12/1899 1:03:51
(only time is correct) and 14/02/2006 0:00:00 (only date is correct). And I
can’t find the format function switch in the SQL management studio, like I
could in access.

Why aren’t there smaller data types for only time and date separated? Is it
because they are all represented as 4 byte integers, so I could use smallint
instead and convert it to date/time when needed? If so, what’s the best
practice?

Is there any way to fix my problem so it displays those data correctly?

Thanks for help
Davor

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:56 PM
=?Utf-8?B?TmlnZWwgUml2ZXR0?=
 
Posts: n/a
Default RE: time data type

You are confusing storage with presentation - which isn't surprising if you
re used to Access.

SQL Server will default to storing dates and times in datetime columns. The
fact that this will hold both a dat and time is immeterial - you don't have
to store both portions.
What is displayd is up to you - clients will probably default to displaying
both date and time but you can probably override that.

Your times should have a date of 19000101 as that is a 0 date in sql server
so you may have had a problem with your import.

Note that smalldatetime only holds minutes and datetime is not accurate to
the millisecond. Smalldatetime holds dates from 19000101 to 20790606 and
datetime from 17530101 to 99990101 so they may not be good for your data. If
you use other datatypes to store the data you may have problems with date
arithmetic.

To return just dates or times

convert(varchar(8),dte,112)
convert(varchar(8),dte,108)




"Davor" wrote:

> Hello
>
> I have imported some mdb tables to SQL server 2005
>
> Problem is that in access, you could specify date/time data type and use
> format to display whatever you like: date or time, or both. But now, in SQL
> server, data that was formatted as time is displayed as 30/12/1899 1:03:51
> (only time is correct) and 14/02/2006 0:00:00 (only date is correct). And I
> can’t find the format function switch in the SQL management studio, like I
> could in access.
>
> Why aren’t there smaller data types for only time and date separated? Is it
> because they are all represented as 4 byte integers, so I could use smallint
> instead and convert it to date/time when needed? If so, what’s the best
> practice?
>
> Is there any way to fix my problem so it displays those data correctly?
>
> Thanks for help
> Davor
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:56 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com