November 1, 2005 at 7:35 pm
Hi,
I'm trying to select a max value from a timedate field. The problem I'm having is that its picking up "12:49am" as greater than "01:30am" - I was wondering why this is..
Is there any way that I can get the value to be displayed as 00:49am in my database? or how about using 24 hour time?
November 1, 2005 at 8:25 pm
If you can provide the table definition and the query you're using it would be most helpful
--------------------
Colt 45 - the original point and click interface
November 1, 2005 at 8:29 pm
SELECT MAX(to_time) as max1 FROM rolling_average
table name: rolling_average
DateTime field: to_time
November 1, 2005 at 8:38 pm
Hmmm ... something that simple ...
Can't reproduce it on my servers, must be something in you environment.
CREATE TABLE #tm (
to_time datetime
)
INSERT INTO #tm VALUES ('1 Nov 2005 12:49am')
INSERT INTO #tm VALUES ('1 Nov 2005 01:29am')
SELECT MAX(to_time) as MaxTime
FROM #tm
DROP TABLE #tm
This returns 1:29am.
--------------------
Colt 45 - the original point and click interface
November 1, 2005 at 8:47 pm
What version of SQL server are you using? I think I'm using 2003. I created the same table as in your example and for some reason still get the 12:49 value :'(
November 1, 2005 at 9:14 pm
I don't think you're using SQL Server 2003 as there hasn't been a new version since SQL Server 2000 and SQL Server 2005 hasn't been released yet
Run SELECT @@VERSION in query analyzer and you should get something similar to the following. This is from SQL Server 2000 SP4 running on Windows Server 2003.
-------------------------------------------------------
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005 23:18:38
Copyright (c) 1988-2003 Microsoft Corporation
Developer Edition on Windows NT 5.2 (Build 3790: Service Pack 1)
--------------------
Colt 45 - the original point and click interface
November 1, 2005 at 9:19 pm
Thanks.. you can tell im a beginner
Well Im sorry to have wasted your time, I had accidently made it a varchar not a datetime, so thats why I was getting my probs..
Thanks for your help!
Viewing 7 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply