Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
JimJudge
Starting Member
7 Posts |
Posted - 2003-07-19 : 05:54:34
|
| SQL 2000I have a date field (datetime) and hour field (0 - 23 int) and a minute field (0 - 59 int) in a table. Some of the records have the date entered without the time (e.g. 7/19/2003). I need the date field to show the date and time for a graphing routine. So, I wrote a query using DateAdd to add the hours and minutes to the existing date. UPDATE DataLogSET rDateTime = DATEADD(Minute, DataLog.rMinute, DATEADD(Hour, DataLog.rHour, rDateTime))WHERE JobID = 1Worked fine except when the time was midnight, hour = 0, minute = 0 the date remained without the time.I tried just adding the time from the keyboard, typing '12:00:00 AM' after the date. That didn't work either. Yet I can see other dates with '12:00:00 AM' in the date field.Is there something I am missing? I can't explain what looks like inconsistant behavoir. |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-07-19 : 14:50:55
|
| Yes, you missed a well-knowed fact that SQL Server can not store inDateTime data type field only Date without Time part. So, if you seeon your screen only date that just means that your client applicationcuts off Time part (only if this is 00:00:00 I suppose) before sendingit onto your screen. Surely, this Time part remains intact in the table.- Vit |
 |
|
|
|
|
|