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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-04-18 : 09:42:41
|
| Greg writes "I'm having trouble finding a week() function. There's one in ColdFusion, and Oracle. Here's my query: select realcurrentWeight from tblVisit where acctid = '#acctId#' and week(visitdate) = #week(curntdate)# The "week(visitdate)" produces this error: Microsoft][ODBC SQL Server Driver][SQL Server]'week' is not a recognized function name.I'm trying to make sure the curntdate is in the same week as the realcurrentweight." |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2002-04-18 : 10:00:29
|
| You need to use the DatePart function:SELECT realcurrentWeight FROM tblVisit WHERE acctid = '#acctId#' AND DatePart(wk,visitdate) = DatePart(wk,curntdate)Since you're comparing two date values, you can also use the DateDiff function:SELECT realcurrentWeight FROM tblVisit WHERE acctid = '#acctId#' AND DateDiff(wk,visitdate,curntdate)=0These functions are detailed in Books Online. |
 |
|
|
vganesh76
Yak Posting Veteran
64 Posts |
Posted - 2002-05-14 : 10:10:27
|
| you can also use the datename function: select realcurrentWeight from tblVisit where acctid = '#acctId#' and datename(wk,visitdate)= datename(wk,curntdate)Enjoy working |
 |
|
|
|
|
|