1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

To list all sundays between two dates

Discussion in 'Databases' started by sscheral, Jul 24, 2008.

  1. #1
    To list all sundays between two dates

    /*Example for datediff : getting no of days passed since 01-01-2004*/
    declare @datevar datetime
    declare @t int
    declare @day varchar(20)
    set @datevar = '1/1/2008'
    set @t = datediff(dd,@datevar,getdate())-- [No of days since 01-01-2004]
    declare @cnt int
    set @cnt = 0

    while @T > @cnt
    begin

    set @day = DATENAME(dw, getdate() - @cnt)
    if @day = 'Sunday'
    begin
    select getdate() - @cnt as Sundays
    end

    set @cnt = @cnt + 1
    end
     
    sscheral, Jul 24, 2008 IP
  2. lv211

    lv211 Peon

    Messages:
    168
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You might want to specify the language that is written in.

    Why are you posting that in this forum? Is that related to databases?
     
    lv211, Jul 25, 2008 IP