Quantcast
Channel: Getting started with SQL Server forum
Viewing all articles
Browse latest Browse all 9243

Recent Date, Last date and Date before that

$
0
0

What is the way to reterieve the latest date, Last date before that .....I need to use this for version maintenance table.

I need to do this withouth doing max...below  is my query

declare

@version varchar(10)='@VERSION'

--declare @version varchar(10)= 'Daily Planet'

update

dbo.Version_Controlset [VERSION TYPE]='Previous'wheredatediff(d,[SUBMISSION DATE],(getdate()))= 1

update

dbo.Version_Controlset [VERSION TYPE]='Archive'wheredatediff(d,[SUBMISSION DATE],getdate())> 1

if

exists(select [VERSION TYPE] fromversionwhere [SUBMISSION DATE]=convert(char(10),getdate(),101)

and dbo.Version_Control=@versionand [type]='Current')

and

notexists(select [VERSION TYPE] fromversionwhere [SUBMISSION DATE]=convert(char(10),(getdate()),101)

and dbo.Version_Control=@versionand [VERSION TYPE]='Final')

update dbo.Version_Controlset [VERSION TYPE]='Current'wheredatediff(d,[SUBMISSION DATE],getdate())=0

else

update dbo.Version_Controlset [VERSION TYPE]='Archive'wheredatediff(d,[SUBMISSION DATE],(getdate()))= 0

---------------------------


SPPandey


Viewing all articles
Browse latest Browse all 9243

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>