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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:20:10+00:00 2026-05-26T13:20:10+00:00

I am creating a timer job in VS for sharepoint, and I want to

  • 0

I am creating a timer job in VS for sharepoint, and I want to create a Date object that only has a month and day. The reason for this is because I want this job to run annually on the specific date.

If it’s not possible with a date object, then how would you go about doing this?

Here’s what I’ve got:

DateTime value = new DateTime(2010, 1, 18);
  • 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-26T13:20:11+00:00Added an answer on May 26, 2026 at 1:20 pm

    Well, you can create your own type – but a DateTime always has a full date and time. You can’t even have “just a date” using DateTime – the closest you can come is to have a DateTime at midnight.

    You could always ignore the year though – or take the current year:

    // Consider whether you want DateTime.UtcNow.Year instead
    DateTime value = new DateTime(DateTime.Now.Year, month, day);
    

    To create your own type, you could always just embed a DateTime within a struct, and proxy on calls like AddDays etc:

    public struct MonthDay : IEquatable<MonthDay>
    {
        private readonly DateTime dateTime;
    
        public MonthDay(int month, int day)
        {
            dateTime = new DateTime(2000, month, day);
        }
    
        public MonthDay AddDays(int days)
        {
            DateTime added = dateTime.AddDays(days);
            return new MonthDay(added.Month, added.Day);
        }
    
        // TODO: Implement interfaces, equality etc
    }
    

    Note that the year you choose affects the behaviour of the type – should Feb 29th be a valid month/day value or not? It depends on the year…

    Personally I don’t think I would create a type for this – instead I’d have a method to return “the next time the program should be run”.

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

Sidebar

Related Questions

Is it possible to check whether a SharePoint (actually WSS 3.0) timer job has
I was creating a countdown timer using javascript; I can use jQuery. I want
I'm creating a PowerShell script that I'm going to execute using Start-Job . The
I'm trying to create a cron job that will send a weekly newsletter. I
I'm creating a day planner using jquery, draggable and droppable. When a job is
So, we are going to be creating a view that has interchangeable images. Basically,
i want to output an array containing numbers. I'm creating the array like this
This is my first time creating a custom action so I'm a bit lost.
This is the first time I'm creating an open-source project, and I've decided (based
When creating database tables I'm often stumped when trying to name my time/date/timestamp fields.

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.