May 18, 2004 at 4:05 pm
May 18, 2004 at 8:12 pm
Not sure what you mean. What's "BIG" and "One Day"? Can you provide some actual dates with examples? I suspect you want to use a CASE statement, just not sure how to structure it.
May 19, 2004 at 12:18 am
fix question
fld_date_from = @Date_from +'-'+ @Time_from
fld_date_to = @Date_end +'-'+ @Time_end
May 19, 2004 at 4:30 am
As long as you get both to resolve to a real datetime value (I sugest put into a datetime variable first) then you can use a case state. However due to rounding you might want to use minutes or seconds instead.
24 hr = 1440 min
24 hr = 86400 sec
So for seconds something like so
CASE WHEN DateDiff(s,Date1,Date2) > 86400 THEN 1
ELSE 2 END
May 19, 2004 at 7:31 am
how to do this
can i get any help o do this
thnks a lot ilan
May 19, 2004 at 10:37 pm
How to do it ???
use CASE WHEN
and put it all in one ????
thnks a lot ilan
May 20, 2004 at 6:56 am
Hi Midan,
Guess there might be a little problem with the language barrier thing... let me see if I can clear it up...
I believe your problem is that you want to determine the difference between the two date/time pairs of columns and if the difference is more than 24 hours, you want to set Fld1 to "1". If the difference is less than or equal to 24 hours, you want to set Fld1 to "2".
The example below shows how to do this in a SELECT (for testing purposes) which you can modify to do your INSERT. I've included all of the variable declarations and "sets" just for testing purposes... the "meat" of this problem is in the CASE statement of the example. (by the way... June only has 30 days in it, not 31. )
DECLARE @Date_End VARCHAR(10)
DECLARE @Time_From CHAR(5)
DECLARE @Time_Fnd CHAR(5)
SET @Date_End = '01/07/2004'
SET @Time_From = '07:00'
SET @Time_End = '08:00'
CASE
WHEN CONVERT(DATETIME,@Date_End,103)+CONVERT(DATETIME,@Time_End)
-CONVERT(DATETIME,@Date_From,103)+CONVERT(DATETIME,@Time_From) > 1
THEN 1
ELSE 2
END AS Fld1
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply