Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

George C.K. Low

Posted

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...

George C.K. Low

Posted

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...

George C.K. Low

Posted

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

Posted

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.

George C.K. Low

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...