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
 General SQL Server Forums
 New to SQL Server Programming
 SQL Combining 2 columns

Author  Topic 

Front-Line
Starting Member

4 Posts

Posted - 2009-10-28 : 11:00:07
Hello to all, i'm currently importing an mdb file into excel using MS Query, in this table, I got about 5 columns which 2 of them are:

Hour, Minute

The data under Hour are, 8,8,9,9,10,10..
and under Minute, it's 0,30,0,30,0..

so in excel it looks like
8 0
8 30
9 0
9 30

what I want to do is, create 1 column that will have these 2 columns combined together in Ms Query.

How should that be done ?

Thanks to all,

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-28 : 11:42:44
select hour + ' ' + minute from...
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-10-28 : 11:46:30
so that you get 08:00,08:30, etc.?
select convert(char(5),dateadd(mi,[minute],dateadd(hour,[hour],0)),108)

You should store these as DATETIME data type.

Jim


Everyday I learn something that somebody else already knew
Go to Top of Page

Front-Line
Starting Member

4 Posts

Posted - 2009-10-28 : 12:03:08
I tried to add the code but I got an error message.

I'm kinda new to this... Here's the code that I currently have:

SELECT DISTINCT IDP.Name, LastName, Date, Hour, Minute, Data1, Data2
FROM `\\filexta\data\`.IDP IDP
WHERE (IDP.Date=?)


Could you tell me what should be the entire code ?

Thanks,
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-28 : 12:04:33
First you should post that error message.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Front-Line
Starting Member

4 Posts

Posted - 2009-10-28 : 13:06:40
it said that my query is not runnning in graph mode
Go to Top of Page
   

- Advertisement -