About The Days problem in Date

  • How to find out in a month how many time friday or sunday count

    as well as if i want to print the last friday of the month then how to do please suggest

  • convert(varchar(6),@dte,112)+'01)

    will give the start of the month.

    dateadd(dd,-1,convert(varchar(6),dateadd(mm,1,@dte),112)+'01)

    the end of the month.

    uses datediff(ww,..,...) for these two dates to give the number of week boundaries between them then add/subtract 1 depending on the datepart(dw,...) values of the two dates.

    This can be done all in one statement using case expressions.


    Cursors never.
    DTS - only when needed and never to control.

  • But this does not the number of fridays in a particular month. So how do i find that out.

    quote:


    convert(varchar(6),@dte,112)+'01)

    will give the start of the month.

    dateadd(dd,-1,convert(varchar(6),dateadd(mm,1,@dte),112)+'01)

    the end of the month.

    uses datediff(ww,..,...) for these two dates to give the number of week boundaries between them then add/subtract 1 depending on the datepart(dw,...) values of the two dates.

    This can be done all in one statement using case expressions.


    Paras Shah

    Evision Technologies

    Mumbai, India


    Paras Shah
    Evision Technologies
    Mumbai, India

  • Datediff gives the number of weeks. based on the current day, you can calculate wheterh there are 4 or 5 fridays. Take a few minutes and work it on paper, then try sql. Post your attempt and we'll help, but we hate to do the work for you.

    Steve Jones

    steve@dkranch.net

Viewing 4 posts - 1 through 3 (of 3 total)

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