automatically inserting system date on table
i have a problem to finishing my work for graduate.. plz give a solution :confused:
i have 1 table : 'period', i'm using MS SQL SERVER 2000. and i want to automatically inserting system date (without sunday) of this month (next month by following the system month) into table 'period' when i click a button on my form.
example : i input a 25 period in text1.text and i click a 'process' button. i confuse how to automatically take the whole date of this month (without sunday) and inserting them on my 'period' table.
i need a result like below :
period total
11/01/2006 0
11/02/2006 0
11/03/2006 0
11/04/2006 0
11/06/2006 0 (the date jump to sixth november 2006, cause fifth november is sunday).
i really appreciate your help.. thank you very much for you advance,
Serzilq
Re: automatically inserting system date on table
Welcome to the forums. :wave:
What are you building your front end in?
Re: automatically inserting system date on table
This T-SQL - put into a stored procedure - will do what you want...
Code:
Declare @StartDate datetime
Declare @LoopDate datetime
Set @StartDate='2006-10-01'
Set @LoopDate=@StartDate
While DatePart(mm,@StartDate)=DatePart(mm,@LoopDate)
Begin
If DatePart(dw,@LoopDate)<>1 Insert into SomeTable Values (@LoopDate)
Set @LoopDate=DateAdd(dd,1,@LoopDate)
End
Do you know how to create and execute stored procedures?