Learn when you want, where you want with convenient online training courses. Sign up now!
Experts Exchange Solution brought to you by
"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.
This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.
-- CREATE TABLE FOR TESTING
CREATE TABLE #TestTable (
-- DECLARE VARIABLES TO HOLD USER INPUT AND NO. OF DAYS
DECLARE @Mth TINYINT,
-- SET DEFAULT VALUE
SET @Counter = 1
-- SET MONTH AND YEAR VALUE (USER INPUT)
SET @Mth = 4
SET @Year = '2008'
1. Differentiate between 30 day month vs 31 days
2. Also check to see if it is a leap year or not for February
IF @Mth IN (1,3,5,7,8,10,12)
SET @NumOfDays = 31
IF @Mth = 2
IF MONTH(Dateadd(day, 1, @Year+'-02-28')) = 3
BEGIN SET @NumOfDays = 28 END
BEGIN SET @NumOfDays = 29 END
BEGIN SET @NumOfDays = 30 END
-- INSERT DATES INTO OUR TEST TABLE
While @Counter <= @NumOfDays
INSERT INTO #TestTable (Date)
SELECT CAST(@Year+'-'+Cast(@Mth as varchar(2))+'-'+Cast(@Counter as varchar(2)) as Datetime)
SET @Counter = @Counter + 1
DROP TABLE #TestTable
Open in new window
Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.