Hi,
I'm trying to check if a row was created yesterday?
This does not seem to work?
(MyId == "10") && DATEPART("dd",GETDATE()) == (DATEPART("dd",MyDateTimeColumn) - 1)
Does anybody know how I can accomplish this?
Many thanks.
Two things...First, you should surround your DATEPART equality checks in parenthesis.
(MyID == "10") && ( datepart stuff here )
Second, you probably shouldn't subtract one from the result of datepart("dd",MyDateTimeColumn), instead, you should use datepart("dd",dateadd("dd",-1,MyDateColumn))|||
Hi Mr. Hat,
I would try something similar to
(MyId == "10") && MyDateTimeColumn == DATEADD("dd", -1, GetDate())
Hope this helps,
Andy
|||
Andy Leonard wrote:
Hi Mr. Hat,
I would try something similar to
(MyId == "10") && MyDateTimeColumn == DATEADD("dd", -1, GetDate())
Hope this helps,
Andy
HAHAHAHA! (Sorry, but I blindly overlooked the part where the user was comparing day of months.) Yeah, do what Andy suggests. There's no need to compare "days" to each other. Just compare the dates. However, cast them to dt_dbdate first, to eliminate time.
(MyId == "10) && ((DT_DBDATE)[MyDateColumn] == (DT_DBDATE)DATEADD("dd",-1",GetDate()))|||
Brilliant! It worked.
Thank you so much!!
No comments:
Post a Comment