This is my first question ever on any forum.
I am working on a Sybase procedure where I need to get last month's date {as MMddyyyy} to filter records against a date field. The way I am currently doing it seems to be rather patchy though it is working.
Is there a better way of doing this?Code:CREATE PROC sy_previous_month_report AS BEGIN DECLARE @month CHAR(3) , @year CHAR(4) , @date CHAR(12) SELECT @month = substring(convert(char(20), dateadd(mm, -1, getdate()), 106), 4, 3) SELECT @year = substring(convert(char(20), getdate(), 106), 8, 4) IF @month = "Dec" SELECT @year = substring(convert(char(20), dateadd(yy, -1, getdate()), 106), 8, 4) SELECT @date = @month+" "+@year+"%" ...
TIA!![]()


Reply With Quote


Bookmarks