473,466 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Storing Time in SQL Server 2000



HI there,

I currently store the date using the getdate() function

but how can I store just the time or seperate the time off from a
datetime datatype?

M3ckon

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #1
4 6504
SQLServer doesn't have separate DATE and TIME datatypes so store the date
and time together. If the date isn't relevant then just store some dummy
date with the time - if you don't specify the date when you insert a time as
a formatted string then it will default to 1900-01-01.

Separating out the time for display purposes may be best done in your
application but you can also do it in SQL using the CONVERT function. For
example:

CONVERT(CHAR(8),CURRENT_TIMESTAMP,8)

--
David Portas
SQL Server MVP
--
Jul 20 '05 #2
>>>I currently store the date using the getdate() function <<

1) Now that you can, start to use the Standard SQL CURRENT_TIMESTAMP
instead of that old Sybase proprietary function.

2) I think that you conceptual model of time is wrong. You are not
storing just the date, an instant in time so small it does not exist,
but the duration of 24 hours that began at midnight. Time is a
continuum and continuums do not have discrete points.

Look Zeno's Paradoxes (The Arrow is the best one for this) and
Einstein's physics.
but how can I store just the time or seperate the time off from a

datetime datatype? <<

Look at the temporal library routines for help. Force everything to
one particular date and extract the time part. This is a kludge, of
course. The real question is what does that point in time mean in
your data model without reference to a date which is a duration in the
continuum? Read some of Rick Snodgrass's books and paper on the
subject.
Jul 20 '05 #3


I just wanted to split them up for display purposes ... but Isuppose
that can be done on the display tier of the app
good point though

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #4
m3ckon (an*******@devdex.com) writes:
I just wanted to split them up for display purposes ... but Isuppose
that can be done on the display tier of the app


Yes, that is the better place to do it.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve D | last post by:
I've looked all over but can't find a solid answer. I've got a function that runs from a View and when the function runs the first time it is calculating a Temperature for a group of Formulas. ...
6
by: gv | last post by:
Hi all, I need to store values in a client application then later when done send them to SQL 2000. I know there is several ways to do this but, looking for the fastest , and most effient way...
5
by: Don Vaillancourt | last post by:
I'm building a system when one can upload a document to the website. I will be storing the document on the hard-drive for quick/easy access, but I was also thinking of storing it in an existing...
3
by: Ringo Langly | last post by:
Hi folks, Is it possible to store Binary Files in MS SQL 2000 ??? Say I have a 100K PDF or a 150K word document. Is it possible to store this in a field in MS SQL and pull it out somehow? ...
6
by: Kieran Benton | last post by:
Hi, I have quite a lot of metadata in a WinForms app that I'm currently storing within a hashtable, which is fine as long as I know the unique ID of the track (Im storing info on media files). Up...
8
by: rgparkins | last post by:
Hi I am creating a sign-up process on a web site much like that of a wizard form. I have browsed many sites to look for examples of how to store the entry data, so that the user can go back and...
6
by: (PeteCresswell) | last post by:
User wants to go this route instead of storing pointers in the DB and the documents outside. Only time I tried it was with only MS Word docs - and that was a loooong time ago - and it seemed to...
7
by: Tzanko | last post by:
As we all know, there is a 8060 bytes size limit on SQL Server rows. I have a table which requires a number of text fields (5 or 6). Each of these text fields should support a max of 4000...
4
by: Zeljko Bilandzija | last post by:
Hy, could someone help me in this: In design mode, i want to put pictures in database. I made column named pics, and its type as image. How can I put pictures or some address of these pictures...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.