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 8269779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:20:39+00:00 2026-06-08T06:20:39+00:00

SELECT medicalDate FROM PilotMedical WHERE pilotID = ‘1’ This will get the date of

  • 0
SELECT medicalDate
FROM PilotMedical
WHERE pilotID = '1'

This will get the date of the medical exam. However, I need to return when this medical exam expires, which is one year from the date, and the last day of the month. For example, if I get a medical exam on January 12th, 2012, it will expire January 31st, 2013.

medicalDate is a “date” type.

How can I do this in SQL? Basically I want to have it return 1/31/2013 for a medical exam any time in January 2012.

If not, I guess I can do it in VB. I’m much more interested in learning how to do it in VB as I don’t plan on working with VB the rest of my life

EDIT:

This will get the last day of the month

--Last Day of Any Month and Year
DECLARE @dtDate DATETIME
SET @dtDate = '8/18/2007'
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@dtDate)+1,0))
LastDay_AnyMonth

ResultSet:
LastDay_AnyMonth
———————–
2007-08-31 23:59:59.000

Now looking for how to add a year to this

  • 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-06-08T06:20:42+00:00Added an answer on June 8, 2026 at 6:20 am

    This demonstrates one way to do it:

    DECLARE @OrigDate datetime
    DECLARE @NewDate datetime
    
    SET @OrigDate = '1/12/2012'
    
    SET @NewDate = DATEADD(Day, -1, DATEADD(Month, 1, Cast(CAST(Month(@OrigDate) as varchar) + '/1/' + CAST((Year(@OrigDate)+1) as varchar) as datetime)))
    

    Step 1: Create a new date in the same month, next year, but on the 1st.

    Step 2: Adds one month

    Step 3: Subtracts one day

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SELECT Id,Date,Name FROM people WHERE DATEPART(hh,Date) >= 7 AND DATEPART(hh,Date) <= 8 Order by
select count(*) as count from table group by foreign_id order by count This returns
SELECT * FROM [makes$] WHERE Corporate Name='Champion Enterprises, Inc.' I'm running this query on
SELECT plaka, party_id, sum(inf) i FROM party_sehir GROUP BY party_id, plaka This is my
SELECT * FROM t WHERE c REGEXP '.*\(..\).*'; This didn't work. It returned many
select max(DELIVERY_TIMESTAMP) from DOCUMENTS; will return the time that the latest document was delivered.
select * from table where key='çmyk' when i run this query on table that
SELECT `attendence`.`u_id` , DATE_FORMAT(date,'%d-%m-%Y') as `date`, `attendence`.`checkin`, `attendence`.`checkout`, `users`.`firstname`, `users` .`lastname` FROM `attendence` INNER
SELECT REPLACE([strUrl], '/myoldurl', '/mynewurl') FROM [UrlRewrite] If strUrl is /myoldurl/myoldurl_something_else , it returns /mynewurl/mynewurl_something_else
select tf.Id,tf.Name,tf.LName,tf.Rank,tf.Category where tf.Id not in (select fighter_id from tbl_player_fighter where league_id=91) and tf.Status

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.