Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AdamWest
Constraint Violating Yak Guru
360 Posts |
Posted - 2011-04-04 : 18:08:54
|
| HI I have to make a query that will want all dates on the server table that are between a from and to dates that has been coded in the app. I am wondering if the date types have to match.on the server the date looks like: it is Delivery_date2010-09-21 00:00:00 and the dates in the app defined here:my question is how would you code that you want to select those rows in the table which are greater or equal to from date and less = the to date? DateTime _dateFrom; public DateTime DateFrom { get { return _dateFrom; } set { _dateFrom = value; RaisePropertyChanged("DateFrom"); } } DateTime _dateTo; public DateTime DateTo { get { return _dateTo; } set { _dateTo = value; RaisePropertyChanged("DateTo"); } } |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2011-04-04 : 18:15:10
|
| It's [robably a datetime in the database so you could compare with a datetime if you can map the datatype from the app or use a character string with format yyyymmdd hh:mm:ss.mmm==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-04-04 : 19:29:23
|
| To add to what Nigel said, if the data type in the database is not datetime or smalldatetime - for example if it is a varchar, the filtering you want to do may not work as you expect, because it would do string sort instead of sorting as datetime. DateTime data type on the C# side is compatible with datetime on server, so you sre ok there. |
 |
|
|
|
|
|