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 |
Karander
Starting Member
34 Posts |
Posted - 2006-09-24 : 10:49:44
|
HiHow to check if a datetime field equals precisely month and year without using two conditions??For Instance: November and 2006 yearThanks :) |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-09-24 : 11:20:03
|
declare @dateFrom datetime, @dateTo datetimeselect @dateFrom = '20061101', @dateTo = dateadd(m, 1, @dateFrom)select *from YourTablewhere YourDateCol between @dateFrom and @dateToGo with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
Karander
Starting Member
34 Posts |
Posted - 2006-09-24 : 11:43:11
|
hey!Thanks but ...will not it also include 2006-12-01 date? |
 |
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2006-09-24 : 11:49:38
|
true. forgot about inclusivness of between.a little fix:select *from YourTablewhere YourDateCol >= @dateFrom and YourDateCol < @dateToGo with the flow & have fun! Else fight the flow blog thingie: http://weblogs.sqlteam.com/mladenp |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-09-24 : 20:41:58
|
http://sql-server-performance.com/fk_datetime.aspMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|