Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, i want to take a date as same as database my query as follows

SELECT * FROM news_master WHERE NW_NewsDate between '2014-01-07 00:00:00' AND '2014-01-07 23:59:00' ORDER BY NW_SerialNo ASC

output for column Paper_date is "1/12/2014 12:00:00 AM" but database column consists the Paper_date "2014-01-19"

So i want same output of Paper_date as same as database value i.e "2014-01-19" ,So what is alternate for this
Posted
Updated 6-Jan-14 22:57pm
v3
Comments
BK 4 code 7-Jan-14 4:55am    
Not clear , can you please check your code once again , or please share your whole code here.
Arslan Elahi 7-Jan-14 5:13am    
can you please show your table structure ? what datatype you have select for your dates column n where you get the dates to compare either from textboxes or somewhere else?

1 solution

Hai
use DateTime format for convert date as u want,for this u need to specify the column name exactly for convert date,try to use
C#
SELECT DATE_FORMAT(Paper_date, '%Y/%m/%d') FROM news_master WHERE NW_NewsDate between '2014-01-07 00:00:00' AND '2014-01-07 23:59:00' ORDER BY NW_SerialNo ASC 


If not work pls go through convert datetime in mysql,i am known in sql server.

Regards
AravindB
 
Share this answer
 
Comments
SVT02 7-Jan-14 5:21am    
Thanx Aravind
RKparmar 7-Jan-14 6:20am    
Hi use this :
SELECT select CONVERT(varchar(10),NW_NewsDate,110) FROM news_master WHERE NW_NewsDate between '2014-01-07 00:00:00' AND '2014-01-07 23:59:00' ORDER BY NW_SerialNo ASC

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900