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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:49:32+00:00 2026-05-18T03:49:32+00:00

I have this information from a Table: The due date day and month (eg.

  • 0

I have this information from a Table: The due date day and month (eg. 16/11 for 16th November) of events that repeat every year.

I need to create a View, sorted by how far it is in the future.

(eg. If it is currently 16 Nov 2010, then 31/12 means 31 Dec 2010 and it comes before 1/1 which means 1 Jan 2011)

Let’s assume the Event table has these 3 columns

|------------------------|
|         Event          |
|------------------------|
| ID | DueDay | DueMonth |
|------------------------|

Thanks in advance!

  • 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-18T03:49:32+00:00Added an answer on May 18, 2026 at 3:49 am

    Any event in the table with a dues day/month ahead of current day/month will occur *this*year. Any event with a due day/month behind current day/month will occur next year. Any event due next year is further than any event due this year.

    Now that being said, what you ask for is not possible because you ask for ...a View, sorted by... which is a concept that does not exists. Views are not sorted. Only queries are sorted. So you can create a view that projects the proper event date and then the query from the view must use ORDER BY to get the events sorted by event date:

    create table Events (
     id int identity(1,1) not null, 
     DueDay int not null, 
     DueMonth int not null);
    go
    
    insert into Events (DueDay, DueMonth) 
    values  (1,1), (15,11), (31,12);
    go
    
    create view eventsDate as
    select id, dateadd(day, DueDay-1,
      dateadd (month, DueMonth-1,
         dateadd(year, 
             case when DueMonth < month(getdate()) or
                (DueMonth = month(getdate()) and 
                 DueDay < day(getdate()))
             then year(getdate())-1899
             else year(getdate())-1900 end, 
             '19000101'))) as DueDate
        from Events;
    

    To get the events by order, the query must include an order by:

    select * from eventsDate order by DueDate desc;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that writes information to file. This information is used post-execution
I have a query that is created in VBA and selects column information from
I have a query like this: SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE FROM MY_DB.INFORMATION_SCHEMA.COLUMNS WHERE
This is silly, but I haven't found this information. If you have names of
I don't know if I have all the information needed to phrase this question
I have this code in jQuery, that I want to reimplement with the prototype
I have a table named sessions setup like this: ################################# # set # timestamp
I have this idea for a free backup application. The largest problem I need
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM
I have this line in a javascript block in a page: res = foo('<%=

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.