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 |
|
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2012-01-20 : 00:33:17
|
| Hey all,writing the following querymy finishdatetime variable is stored as a datetime and is in the form of dd/mm/yyyy xx:xx:xx.xx etc,SELECT TOP 1000 *, (Select DATEPART(HH, B.FINISHDATETIME)) as HOUR, (Select DATEPART(MM, B.FINISHDATETIME)/30) as 30MINUTEFROM SALES AS BThe query runs but this doesnt work. (Select DATEPART(MM, B.FINISHDATETIME)/30) as MINUTEfor every time that is xx:00 - xx:29 I want the minute column to return 0 and for every time xx:30 - xx:59 I want the minute column to return 1eg (NOTE THIS IS AN EXAMPLE, I HAVE RETURNED * SO THERE WILL BE HEAPS OF COLUMNS)DATE TIME | Hour | 30MIN01/01/2012 4:01:02 PM | 16 | 001/01/2012 5:33:02 AM | 5 | 0I can get the hour by just returning datepart hhbut i was thinking return datepart mm then dividing by 30 but it doesnt seem to workcheers guys |
|
|
pavlos
Yak Posting Veteran
59 Posts |
Posted - 2012-01-20 : 00:35:38
|
| ignore that guysMM returns month..i needed MIand it worksLOL |
 |
|
|
|
|
|