March 6, 2008 at 6:47 am
Hi
Here is how I would do.
the expression : dateadd(dd, 0, datediff(dd, 0, <Colum in DATETIME Format)) actually returns the the date part of the column with the time set to 00:00:00
eg dateadd(dd, 0, datediff(dd, 0, '2008-03-06 14:36:52.823')) returns '2008-03-06 00:00:00'
SELECT CASE
WHEN dateadd(dd, 0, datediff(dd, 0, )) = dateadd(dd, 0, datediff(dd, 0, GETDATE() )) THEN 1
ELSE 0
END AS DateFlag
March 6, 2008 at 6:51 am
Sorry, I may not have explained myself correctly. This change needs to be carried out automatically on the fly as the 0 or 1 value controls part of a ETL.
March 6, 2008 at 9:32 am
This post is strange because it does not have a question at the beginning.
I need to be able to set a flag from 0 to 1 when the datetime field within the same table is equal to today's date.
Does this mean you want to actually update table data? If so, you could do an update like this:
UPDATE MYTABLE
SET Flg = 1
WHERE Flg = 0 AND
CONVERT(VARCHAR,MYDATECOLUMN,101) = CONVERT(VARCHAR,GETDATE(),101)
March 6, 2008 at 9:33 am
somehow I posted above the previous post.... :hehe:
March 6, 2008 at 10:52 am
Hi All,
I need to be able to set a flag from 0 to 1 when the datetime field within the same table is equal to today's date.
What is the best way to implement this?
Thanks
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply