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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HOW TO CHECK MAX DATE IN VARABILE IN SQL SERVER

Author  Topic 

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2015-02-03 : 06:36:48
MY CODE IS NOT RUNNING.IT SHOULD PRINT '1900-01-01' BCOZ TEST TABLE IS BLANK.

DECLARE @CHKDT1 AS DATE
SELECT @CHKDT1 = MAX(CONVERT(DATE,COMPUTEDATE,121)) FROM test

IF (@CHKDT1 = '' OR @CHKDT1 = NULL)
BEGIN
SET @CHKDT1 = CONVERT(DATE,'1900-01-01',121)
END
print @CHKDT1


THANKS,
RAJNI

sz1
Aged Yak Warrior

555 Posts

Posted - 2015-02-03 : 06:51:33
DECLARE @CHKDT1 AS DATE
SET @CHKDT1 = (SELECT MAX(CONVERT(DATE,COMPUTEDATE,121)) FROM test)

IF (@CHKDT1 = '' OR @CHKDT1 IS NULL)
BEGIN
SET @CHKDT1 = CONVERT(DATE,'1900-01-01',121)
END
print @CHKDT1


We are the creators of our own reality!
Go to Top of Page

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2015-02-03 : 07:14:37
THANKS ITS WORKING

THANKS

RAJNI
Go to Top of Page

sz1
Aged Yak Warrior

555 Posts

Posted - 2015-02-03 : 07:16:13
Good stuff.

We are the creators of our own reality!
Go to Top of Page
   

- Advertisement -