Click here to Skip to main content
15,885,895 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<pre lang="xml">This is sample data table.


PURC_ID---------PRICE---------UNIT------------------QTY--------Date_Purchased

IP-16701--------233981--------Samsung Gal S--------1--------7/1/2014 10:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------7/5/2014 10:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------7/22/2014 7:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------8/3/2014 10:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------8/10/2014 8:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------8/15/2014 9:03:59 PM
IP-95975--------180866--------Sony Xperia Z--------1--------8/25/2014 1:31:53 PM
IP-95975--------180866--------Sony Xperia Z--------1--------8/26/2014 1:31:53 PM


This is what I want to do.

If I choose weekly it will get all the data from the current date until the starting date which is Monday. The format will be Monday - Sunday for weekly.

IP-95975--------180866--------Sony Xperia Z--------1--------8/25/2014 1:31:53 PM
IP-95975--------180866--------Sony Xperia Z--------1--------8/26/2014 1:31:53 PM

and If I choose monthly it will display all the data from Day 1 - 31.

IP-16701--------233981--------Samsung Gal S--------1--------8/3/2014 10:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------8/10/2014 8:03:59 PM
IP-16701--------233981--------Samsung Gal S--------1--------8/15/2014 9:03:59 PM
IP-95975--------180866--------Sony Xperia Z--------1--------8/25/2014 1:31:53 PM
IP-95975--------180866--------Sony Xperia Z--------1--------8/26/2014 1:31:53 PM



Thanks for your help.
Posted
Updated 25-Aug-14 21:12pm
v2
Comments
Pheonyx 26-Aug-14 4:25am    
Well, how are you communicating with your database? Is it SQL? Are you using SQLCommands or are you using some sort of ORM such as Entity Framework?

Without that we information we can just say "select them ones within in a given date range"
[no name] 26-Aug-14 4:33am    
u can use between operator..
Member 11036780 26-Aug-14 5:45am    
ya ofcurs you can use between opertr in query ok
[no name] 26-Aug-14 9:24am    
what have tried yet, and where is ur problem
And have you tried between operator in your query
XCode2010 31-Aug-14 22:00pm    
Im using SQL Server 2008 for my database. Yes I heard that between operator but I dont know how I will use it. For example I have a 2 set of drop down list for the start date and end date. Is this correct? "SELECT ProductID,price,ProductName,Qty FROM Transaction bewteen '" + ddldatestart "'AND'" + ddldateend '";

Where ddldatestart and end format is mm/dd/yyyy? How about the time like this "1:31:53 PM"?

1 solution

Try the following SQL statement

SQL
"SELECT ProductID,Price,ProductName,Qty FROM Transaction Where Date_Purchased between '" + ddldatestart + "' AND '" + ddldateend  + "'";
 
Share this answer
 

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