someone_genius
asked on
How to Get Week on perticular Date?
Dear All,
Suppose here is one date say 5 augest 2006.
I want to find the week on that month.
Means 5 augest comes in first week. so I have to display 1
Please guide me,
Thanks in advance,
Prathamesh.
Suppose here is one date say 5 augest 2006.
I want to find the week on that month.
Means 5 augest comes in first week. so I have to display 1
Please guide me,
Thanks in advance,
Prathamesh.
ASKER
Dear JMattias ,
I am Oracle DBA so I don't know much more about SQL serever. I know in oracle that to use to_char so please explain me.
I am Oracle DBA so I don't know much more about SQL serever. I know in oracle that to use to_char so please explain me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
CREATE FUNCTION [ owner_name. ] function_name
( [ { @parameter_name [AS] scalar_parameter_data_type [ = default ] } [ ,...n ] ] )
RETURNS scalar_return_data_type
[ WITH < function_option> [ [,] ...n] ]
[ AS ]
BEGIN
function_body
RETURN scalar_expression
END
Example:
CREATE FUNCTION Getweek (@DATE datetime)
RETURNS int
AS
BEGIN
DECLARE @Day int
Declare @Week int
SET @Day= Day(@DATE)
if @Day <= 7
set @Week = 1
if @Day > 7 and @Day <= 14
.
.
.
.
.
RETURN(@week)
END
Something like that.
Regards
/Mattias
CREATE FUNCTION [ owner_name. ] function_name
( [ { @parameter_name [AS] scalar_parameter_data_type
RETURNS scalar_return_data_type
[ WITH < function_option> [ [,] ...n] ]
[ AS ]
BEGIN
function_body
RETURN scalar_expression
END
Example:
CREATE FUNCTION Getweek (@DATE datetime)
RETURNS int
AS
BEGIN
DECLARE @Day int
Declare @Week int
SET @Day= Day(@DATE)
if @Day <= 7
set @Week = 1
if @Day > 7 and @Day <= 14
.
.
.
.
.
RETURN(@week)
END
Something like that.
Regards
/Mattias
hi,
Any luck?
Regards
/Mattias
Any luck?
Regards
/Mattias
ASKER
Dear All,
Thanks for ur useful feedback.
Now I m closing this thread.
Thanks for ur useful feedback.
Now I m closing this thread.
write a udf/function that returns that for you.
Regards
/Mattias