DATE TIME DATETIME in MYSQL

georgepatotk

Well-known member
Joined
Mar 1, 2004
Messages
431
Location
Malaysia
i am having a DATE field and a TIME field.

For comparison purposes, i need to combine DATE and TIME into DATETIME.
Can anyone show me how? thanks.

I want something like

SELECT RCDATE & RCTIME FROM tblRC

where RCDATE & RCTIME equavalant to DATE field and TIME field.
 
SELECT RCDATE , RCTIME, concat(RCDATE , ,RCTIME) FROM tblRC

works for me!

/Kejpa
 
Wao this is great.

But, my problem is not solved yet.

Code:
SELECT s.SalesPK, s.SalesDate, s.SalesTime, s.TableName
FROM tblSales s

WHERE s.SalesPK <> 0

AND CONCAT(SalesDate,  , SalesTime) >= 2005-11-11 01:00:00
AND CONCAT(SalesDate,  , SalesTime) <= 2005-11-11 14:00:00
ORDER BY s.SalesPK ASC

I wanna show records withon the date duration. but, it doesnt work.
Or I should say, sometimes works, sometimes no...

Help me to figure this out. Thanks...
 
Yeah, I figure out the problem,

Code:
SELECT s.SalesPK, s.SalesDate, s.SalesTime, s.TableName
FROM tblSales s

WHERE s.SalesPK <> 0

AND CONCAT(SalesDate,  , SalesTime) >= 2005-11-11 01:00:00
AND CONCAT(SalesDate,  , SalesTime) <= 2005-11-11 14:00:00
ORDER BY s.SalesPK ASC

This query is working, just I had passed wrong input to the command.
Anyway, Thanks...
 
Why not use BETWEEN key word?

Code:
SELECT s.SalesPK, s.SalesDate, s.SalesTime, s.TableName
FROM tblSales s

WHERE s.SalesPK <> 0

AND CONCAT(SalesDate,  , SalesTime) between 2005-11-11 01:00:00
AND  2005-11-11 14:00:00
ORDER BY s.SalesPK ASC


/Kejpa
 
For such a long time I had been using SQL query, I had never used Between in my program. How stupid am I?

Thanks for your suggestion. You really do me a big favor. And tell me something that is so useful for my future programs. Thanks again for pointing me the BETWEEN.
 
Back
Top