georgepatotk Posted November 11, 2005 Posted November 11, 2005 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. Quote George C.K. Low
kejpa Posted November 11, 2005 Posted November 11, 2005 SELECT RCDATE , RCTIME, concat(RCDATE ,' ' ,RCTIME) FROM tblRC works for me! /Kejpa Quote
georgepatotk Posted November 11, 2005 Author Posted November 11, 2005 Wao this is great. But, my problem is not solved yet. 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 doesn't work. Or I should say, sometimes works, sometimes no... Help me to figure this out. Thanks... Quote George C.K. Low
georgepatotk Posted November 11, 2005 Author Posted November 11, 2005 Yeah, I figure out the problem, 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... Quote George C.K. Low
kejpa Posted November 11, 2005 Posted November 11, 2005 Why not use BETWEEN key word? 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 Quote
georgepatotk Posted November 12, 2005 Author Posted November 12, 2005 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. Quote George C.K. Low
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.