Domanda

Trying to search between two dates to only get certain rows. A 7 day search.

   @date = DateTime.Today
   @date2 = //need it to be the prior 7 days

SelectCommand = "SELECT [DateReceived], [DeviceLevel] FROM [TBLReadings] WHERE [DateReceived=@date] <= [DateReceived=@date2] ORDER BY [DateReceived] DESC;

This is wrong but I hope it explain what I am trying to do - only ever used PHP and MySQL.

È stato utile?

Soluzione

if you are trying to search between 2 dates, you can use between

the query will be something like

select [dateRecieved], [DeviceLevel] from YourTable where DateReceived between @date and @date2 ORDER BY [DateReceived] DESC

in c#, to get 7 days you can use Datetime.Now.AddDays(7)

http://msdn.microsoft.com/en-us/library/system.datetime.adddays.aspx

sorry for the bad english!

edit: that's only the query, use it as a string in the select command

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top