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

  • Home
  • SEARCH
  • 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 6150813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:40:30+00:00 2026-05-23T19:40:30+00:00

My Enddate is 2009-05-31 (using sql server) @EndDate datetime select startdate = dateadd(mm,-12,@EndDate) If

  • 0

My Enddate is 2009-05-31 (using sql server)

@EndDate  datetime
select startdate = dateadd(mm,-12,@EndDate)

If my EndDate = 2009-05-31
with code above will my
StartDate = 31-05-2008 is my code correct?

I want my senddate to be in the month of April so

month(senddate) = month(dateadd(day,-1,dateadd(mm,-1,@EndDate))    

is my code above correct?

  • 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-23T19:40:31+00:00Added an answer on May 23, 2026 at 7:40 pm

    Check below

    declare @EndDate  datetime
    set @EndDate = '20090531'
    select dateadd(mm,0,@EndDate) -- dummy
    ,dateadd(mm,-1,@EndDate) -- april returns 30/4
    ,dateadd(mm,-2,@EndDate) -- march returns 31/3
    ,dateadd(mm,-3,@EndDate) -- february returns 28/2
    

    More simple

    month(senddate) = month(dateadd(mm,-1,@EndDate))
    

    example

    declare @EndDate  datetime
    set @EndDate = '20090531'
    select month(dateadd(mm,-1,@EndDate)) -- returns 4 (april)
    ,month(dateadd(mm,-2,@EndDate)) -- returns 3 (march)
    ,month(dateadd(mm,-3,@EndDate)) -- returns 2 (february)
    

    Start of month

    declare @EndDate  datetime
    set @EndDate = '20090531'
    select CONVERT(VARCHAR(6),(dateadd(mm,-1,@EndDate)),112)+'01'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using SQL Server 2005 Leave Table ID StartDate EndDate 001 04/01/2010 04/02/2010 002 04/02/2010
Using SQL Server 2005 Leave Table ID StartDate EndDate 001 02/03/2010 02/03/2010 002 02/03/2010
consider this sql CREATE VIEW [dbo].[MyView1] ([ID],[VisitDate],[StartDate] ,[EndDate],[MyCount]) WITH SCHEMABINDING AS SELECT id, VisitDate,dateadd(dd,-10,VisitDate),dateadd(dd,10,VisitDate),
I have two DateTime objects: StartDate and EndDate . I want to make sure
Using SQL Server 2005 I want to generate the table values between the two
Using SQL Sever 2005 Table1 ID StartDate EndDate 001 02/23/2010 07/22/2010 002 05/03/2010 null
CREATE VIEW [dbo].[MyView] ([ID],[VisitDate],[StartDate] ,[EndDate]) WITH SCHEMABINDING AS SELECT id, VisitDate,dateadd(dd,-10,VisitDate)persisted, dateadd(dd,10,VisitDate)persisted FROM dbo.Visits
I have the following id eventid startdate enddate 1 1 2009-01-03 2009-01-05 1 2
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17
In an SQL table I keep bookings for various resouces, with a StartDate/EndDate column:

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.