02-21-2012 10:47 AM
I need to find minimum of two dates.
I know I can use min function.
q.what precautions do I need to follow?
q.d1,d2 should be in same format?
Here is the requirement.
create table l1
select min(today()-1,termdate) as testdate format=datetime21.
termdate output testdate
Q) here there are no errors. But for two different termdate inputs I am getting the same output?
02-21-2012 11:14 AM
Comparing datetime. and date directly will be missleading, saying that I would like to retreat my original comments on the format part. Try the following:
select min(today()-1,datepart(termdate)) as testdate format=datetime21.
02-21-2012 11:28 AM
Or, if the time is also important,
select min(datetime()-(24*60*60),termdate) as testdate format=datetime21.
otherwise,make sure that the format is consistent