help get all month Day of the Week like calendar

  • i need help

    to get all month Day of the Week

    like this

    CREATE FUNCTION dbo.udf_DayOfWeek(@dtDate DATETIME)

    RETURNS VARCHAR(10)

    AS

    BEGIN

    DECLARE @rtDayofWeek VARCHAR(10)

    SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate)

    WHEN 1 THEN ‘Sunday’

    WHEN 2 THEN ‘Monday’

    WHEN 3 THEN ‘Tuesday’

    WHEN 4 THEN ‘Wednesday’

    WHEN 5 THEN ‘Thursday’

    WHEN 6 THEN ‘Friday’

    WHEN 7 THEN ‘Saturday’

    END

    RETURN (@rtDayofWeek)

    END

    GO

    Call this function like this:

    SELECT dbo.udf_DayOfWeek(GETDATE()) AS DayOfWeek

    i try to like this

    SELECT

    dbo.udf_DayOfWeek(GETDATE()) AS day1 , dbo.udf_DayOfWeek(GETDATE()-2) AS day2,, dbo.udf_DayOfWeek(GETDATE()-3) AS day3

    need help to create like ROW in clander

    start month TO end of the month

    and after need to put my date

    like 02/2009

    i get all the day of the Week

    start month TO end of the month

    (i must to use my language hebrew in the day name)

    how ?

    TNX

  • You should take a look at the DateName function. It will return the name of the day of the week for you. And it'll be faster than the UDF.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • how to do this ??

    mydate= 02/2009

    and get like this

    fld1 |fld2 |fld3 fld29 | fld30 |fld31

    sun mon Tue ..................... .............................null null null

    mydate= 03/2009

    i get like this

    fld1 |fld2 |fld3 fld29 | fld30 |fld31

    sun mon Tue ..................... sun mon Tue

    how to do it

    TNX

  • HOw are you displaying your calendar? THis sounds like something that you should be using your application for displaying, not the SQL.

    ---------------------------------------------------------
    How best to post your question[/url]
    How to post performance problems[/url]
    Tally Table:What it is and how it replaces a loop[/url]

    "stewsterl 80804 (10/16/2009)I guess when you stop and try to understand the solution provided you not only learn, but save yourself some headaches when you need to make any slight changes."

  • gpspocket (2/25/2009)


    how to do this ??

    mydate= 02/2009

    and get like this

    fld1 |fld2 |fld3 fld29 | fld30 |fld31

    sun mon Tue ..................... .............................null null null

    mydate= 03/2009

    i get like this

    fld1 |fld2 |fld3 fld29 | fld30 |fld31

    sun mon Tue ..................... sun mon Tue

    how to do it

    TNX

    I'll make you a deal... no one ever tells us what the business reason behind doing something like this is. Tell us what the business reason is and I'll give you the code even if I think it's the wrong thing to do. Seriously...

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • ... and, can it be an inline bit of code or do you really need it as a function?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply