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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Time format

Author  Topic 

mahesh_bote
Constraint Violating Yak Guru

298 Posts

Posted - 2007-09-28 : 05:43:00
Hi All,

i m getting the following resultset from one of my query.
i wants timnings to be display with the rage of 12 hours.

2007-09-24 09:45:00.000
2007-09-24 12:32:00.000
2007-09-24 13:03:00.000
2007-09-24 17:35:00.000

required
2007-09-24 09:45:00.000
2007-09-24 12:32:00.000
2007-09-24 01:03:00.000
2007-09-24 05:35:00.000

thanks in advance,

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-28 : 05:56:25
Rage for 12 hours? Please go see a psychiatrist...

SELECT	CASE
WHEN HOUR(Col1) >= 12 THEN DATEADD(HOUR, -12, Col1)
ELSE Col1
END AS NewTime,
Col1 AS OldTime
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-09-28 : 05:58:44
And with 12-hr format you will need, AM/PM as well...other wise how will you separate day from night?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-28 : 06:01:40
He will probably look out through the window.




E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-09-28 : 06:08:17
quote:
Originally posted by Peso

He will probably look out through the window.




E 12°55'05.25"
N 56°04'39.16"






Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-28 : 06:15:17
Oh man...
I we were to questioning every poster WHY he or she wants to do things the way they want, we would never do anything else!

Sometimes I think it is appropriate to ask why when it is obvious that OP is barking at the wrong tree.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-09-28 : 06:21:49
As per me, asking WHY is important, sometimes it clears OP's mind regarding what he really want to do. Also, it will be waste of time if we pour in hundreads of solutions while OP wanted something else or he was not sure what he wanted.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-09-28 : 06:33:02
I think he will get what he asks for.
In most cases the OP writes "urgent", which means it is a homework assignment.
Also that is a lesson for real life. If you don't know what your are working with, you can't ask how to fix it.
And if you know what you are working with, you know what to ask for.

But I have been proven otherwise several times here at SQLTeam



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-09-28 : 06:37:28
quote:
Originally posted by mahesh_bote

Hi All,

i m getting the following resultset from one of my query.
i wants timnings to be display with the rage of 12 hours.

2007-09-24 09:45:00.000
2007-09-24 12:32:00.000
2007-09-24 13:03:00.000
2007-09-24 17:35:00.000

required
2007-09-24 09:45:00.000
2007-09-24 12:32:00.000
2007-09-24 01:03:00.000
2007-09-24 05:35:00.000

thanks in advance,


Why do you want to do this?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-09-29 : 04:47:27
quote:
Originally posted by Peso

He will probably look out through the window.


E 12°55'05.25"
N 56°04'39.16"




Don't have to. Just look at the bottom right corner.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -