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);
Well, you can create your own type – but a
DateTimealways has a full date and time. You can’t even have “just a date” usingDateTime– the closest you can come is to have aDateTimeat midnight.You could always ignore the year though – or take the current year:
To create your own type, you could always just embed a
DateTimewithin a struct, and proxy on calls likeAddDaysetc: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”.