Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 386123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:32:46+00:00 2026-05-12T15:32:46+00:00

Looking for a way to get the date in the format 11/1/2009, which would

  • 0

Looking for a way to get the date in the format “11/1/2009”, which would be the first sunday of next month. I want to run this query after the first sunday in october to get the first sunday of the upcoming month. What is the best method to accomplish this with a T-SQL query?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:32:46+00:00Added an answer on May 12, 2026 at 3:32 pm

    try this:

    Declare @D Datetime 
    Set @D = [Some date for which you want the following months' first sunday]
    Select DateAdd(day, (8-DatePart(weekday, 
        DateAdd(Month, 1+DateDiff(Month, 0, @D), 0)))%7, 
        DateAdd(Month, 1+DateDiff(Month, 0, @D), 0))
    

    EDIT Notes:

    The first of next Month is given by the expression:

    DateAdd(Month, 1+DateDiff(Month, 0, @D), 0)
    

    or by:
    which can be modified to give the first of the month two months from now by changing the 1 to a 2:

    DateAdd(Month, 2+DateDiff(Month, 0, @D), 0) 
    

    EDIT: In response to @NissanFan, and @Anthony: to modify this to return the first Monday Tuesday Wednesday, etc, change the value 8 to a 9, 10, 11, etc….

    Declare @Sun TinyInt Set @Sun = 8
    Declare @Mon TinyInt Set @Mon = 9
    Declare @Tue TinyInt Set @Tue = 10
    Declare @Wed TinyInt Set @Wed = 11
    Declare @Thu TinyInt Set @Thu = 12
    Declare @Fri TinyInt Set @Fri = 13
    Declare @Sat TinyInt Set @Sat = 14
    Declare @D Datetime, @FONM DateTime -- FirstofNextMonth 
    Set @D = [Some date for which you want the following months' first sunday]
    Set @FONM = DateAdd(Month, 1+DateDiff(Month, 0, @D),0)
    
    Select 
      DateAdd(day, (@Sun -DatePart(weekday, @FONM))%7, @FONM) firstSunInNextMonth,
      DateAdd(day, (@Mon -DatePart(weekday, @FONM))%7, @FONM) firstMonInNextMonth,
      DateAdd(day, (@Tue -DatePart(weekday, @FONM))%7, @FONM) firstTueInNextMonth,
      DateAdd(day, (@Wed -DatePart(weekday, @FONM))%7, @FONM) firstWedInNextMonth,
      DateAdd(day, (@Thu -DatePart(weekday, @FONM))%7, @FONM) firstThuInNextMonth,
      DateAdd(day, (@Fri -DatePart(weekday, @FONM))%7, @FONM) firstFriInNextMonth,
      DateAdd(day, (@Sat -DatePart(weekday, @FONM))%7, @FONM) firstSatInNextMonth
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking for a way to get the seconds until @post.created_at date time with timezone.
Am looking for a way to get image of the first page in pdf
MySQL CMD Client will run this file but get half way through and complain
I'm looking for a way to get the size of an instance of a
I'm looking for a way to get the name of the main HTML form
I am looking for a way to get a function in excel to retrieve
I'm looking for a way to get notified in my unix system for new
I'm looking for a way to get and set those oddball chunks in a
I'm looking for a way to get the content of my div in my
I am looking for a way to get a twitter users userid via their

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.