Get next date from day-month
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have one start date and I have next financial year end date's day and month. So based on this data how to get full financial year end date?
ie.
start date = 23rd January,2019
financial year end date's day = 31
financial year end date's month = 3
And I want full date as below :
financial year end date = 31st March,2019
Help me to how to get this date.
c# .net date
|
show 6 more comments
I have one start date and I have next financial year end date's day and month. So based on this data how to get full financial year end date?
ie.
start date = 23rd January,2019
financial year end date's day = 31
financial year end date's month = 3
And I want full date as below :
financial year end date = 31st March,2019
Help me to how to get this date.
c# .net date
1
DateTime dateTime = new DateTime(Date.Now.AddYears(1).Year,financial year end date's month,financial year end date's day)
– ikerbera
Nov 23 '18 at 11:23
I have updated my question. How to do it with that?
– iDipa
Nov 23 '18 at 11:27
Do you have these strings as input ? You're going to have a bad time .. Maybe Humanizr has something on that but I doubt it. Deal withDateTime
structure instead
– Arthur Attout
Nov 23 '18 at 11:29
Same code,Date.Now.AddYears(1).Year
takes todays date, adds a year and gives you the int for the year of the new calculated date. If you still have day and month in the same variables it should work.
– ikerbera
Nov 23 '18 at 11:30
@iDipa, is your financial year end date is correct? please check it is not next year financial end date if start Date is = 23rd Nov 2019
– Prasad Telkikar
Nov 23 '18 at 11:30
|
show 6 more comments
I have one start date and I have next financial year end date's day and month. So based on this data how to get full financial year end date?
ie.
start date = 23rd January,2019
financial year end date's day = 31
financial year end date's month = 3
And I want full date as below :
financial year end date = 31st March,2019
Help me to how to get this date.
c# .net date
I have one start date and I have next financial year end date's day and month. So based on this data how to get full financial year end date?
ie.
start date = 23rd January,2019
financial year end date's day = 31
financial year end date's month = 3
And I want full date as below :
financial year end date = 31st March,2019
Help me to how to get this date.
c# .net date
c# .net date
edited Nov 23 '18 at 11:39
Konamiman
43.1k1598128
43.1k1598128
asked Nov 23 '18 at 11:20
iDipaiDipa
99416
99416
1
DateTime dateTime = new DateTime(Date.Now.AddYears(1).Year,financial year end date's month,financial year end date's day)
– ikerbera
Nov 23 '18 at 11:23
I have updated my question. How to do it with that?
– iDipa
Nov 23 '18 at 11:27
Do you have these strings as input ? You're going to have a bad time .. Maybe Humanizr has something on that but I doubt it. Deal withDateTime
structure instead
– Arthur Attout
Nov 23 '18 at 11:29
Same code,Date.Now.AddYears(1).Year
takes todays date, adds a year and gives you the int for the year of the new calculated date. If you still have day and month in the same variables it should work.
– ikerbera
Nov 23 '18 at 11:30
@iDipa, is your financial year end date is correct? please check it is not next year financial end date if start Date is = 23rd Nov 2019
– Prasad Telkikar
Nov 23 '18 at 11:30
|
show 6 more comments
1
DateTime dateTime = new DateTime(Date.Now.AddYears(1).Year,financial year end date's month,financial year end date's day)
– ikerbera
Nov 23 '18 at 11:23
I have updated my question. How to do it with that?
– iDipa
Nov 23 '18 at 11:27
Do you have these strings as input ? You're going to have a bad time .. Maybe Humanizr has something on that but I doubt it. Deal withDateTime
structure instead
– Arthur Attout
Nov 23 '18 at 11:29
Same code,Date.Now.AddYears(1).Year
takes todays date, adds a year and gives you the int for the year of the new calculated date. If you still have day and month in the same variables it should work.
– ikerbera
Nov 23 '18 at 11:30
@iDipa, is your financial year end date is correct? please check it is not next year financial end date if start Date is = 23rd Nov 2019
– Prasad Telkikar
Nov 23 '18 at 11:30
1
1
DateTime dateTime = new DateTime(Date.Now.AddYears(1).Year,financial year end date's month,financial year end date's day)
– ikerbera
Nov 23 '18 at 11:23
DateTime dateTime = new DateTime(Date.Now.AddYears(1).Year,financial year end date's month,financial year end date's day)
– ikerbera
Nov 23 '18 at 11:23
I have updated my question. How to do it with that?
– iDipa
Nov 23 '18 at 11:27
I have updated my question. How to do it with that?
– iDipa
Nov 23 '18 at 11:27
Do you have these strings as input ? You're going to have a bad time .. Maybe Humanizr has something on that but I doubt it. Deal with
DateTime
structure instead– Arthur Attout
Nov 23 '18 at 11:29
Do you have these strings as input ? You're going to have a bad time .. Maybe Humanizr has something on that but I doubt it. Deal with
DateTime
structure instead– Arthur Attout
Nov 23 '18 at 11:29
Same code,
Date.Now.AddYears(1).Year
takes todays date, adds a year and gives you the int for the year of the new calculated date. If you still have day and month in the same variables it should work.– ikerbera
Nov 23 '18 at 11:30
Same code,
Date.Now.AddYears(1).Year
takes todays date, adds a year and gives you the int for the year of the new calculated date. If you still have day and month in the same variables it should work.– ikerbera
Nov 23 '18 at 11:30
@iDipa, is your financial year end date is correct? please check it is not next year financial end date if start Date is = 23rd Nov 2019
– Prasad Telkikar
Nov 23 '18 at 11:30
@iDipa, is your financial year end date is correct? please check it is not next year financial end date if start Date is = 23rd Nov 2019
– Prasad Telkikar
Nov 23 '18 at 11:30
|
show 6 more comments
3 Answers
3
active
oldest
votes
Try, to allow for a variable start date:
DateTime startDate = new DateTime(2019,1,23);
DateTime financialYear = new DateTime(startDate.Year, 3,31);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
And then format financialYear
to the required format
add a comment |
var startDate = new DateTime(2019,1,23); //23rd January,2019
var financialYearEndDay = 31;
var financialYearEndMonth = 3;
DateTime financialYear = new
DateTime(date.Year,financialYearEndMonth,financialYearEndDay);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
add a comment |
If I understood correctly you just need a new DateTime
object that takes the year from startDate
, but has fixed day and month? Then assuming that you have startDate
as a DateTime
object already you just do:
new DateTime(startDate.Year, financialYearEndMonth, financialYearEndDay)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445751%2fget-next-date-from-day-month%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try, to allow for a variable start date:
DateTime startDate = new DateTime(2019,1,23);
DateTime financialYear = new DateTime(startDate.Year, 3,31);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
And then format financialYear
to the required format
add a comment |
Try, to allow for a variable start date:
DateTime startDate = new DateTime(2019,1,23);
DateTime financialYear = new DateTime(startDate.Year, 3,31);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
And then format financialYear
to the required format
add a comment |
Try, to allow for a variable start date:
DateTime startDate = new DateTime(2019,1,23);
DateTime financialYear = new DateTime(startDate.Year, 3,31);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
And then format financialYear
to the required format
Try, to allow for a variable start date:
DateTime startDate = new DateTime(2019,1,23);
DateTime financialYear = new DateTime(startDate.Year, 3,31);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
And then format financialYear
to the required format
answered Nov 23 '18 at 11:43
Peter SmithPeter Smith
3,67754168
3,67754168
add a comment |
add a comment |
var startDate = new DateTime(2019,1,23); //23rd January,2019
var financialYearEndDay = 31;
var financialYearEndMonth = 3;
DateTime financialYear = new
DateTime(date.Year,financialYearEndMonth,financialYearEndDay);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
add a comment |
var startDate = new DateTime(2019,1,23); //23rd January,2019
var financialYearEndDay = 31;
var financialYearEndMonth = 3;
DateTime financialYear = new
DateTime(date.Year,financialYearEndMonth,financialYearEndDay);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
add a comment |
var startDate = new DateTime(2019,1,23); //23rd January,2019
var financialYearEndDay = 31;
var financialYearEndMonth = 3;
DateTime financialYear = new
DateTime(date.Year,financialYearEndMonth,financialYearEndDay);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
var startDate = new DateTime(2019,1,23); //23rd January,2019
var financialYearEndDay = 31;
var financialYearEndMonth = 3;
DateTime financialYear = new
DateTime(date.Year,financialYearEndMonth,financialYearEndDay);
if (startDate > financialYear)
{
financialYear = financialYear.AddYears(1);
}
answered Nov 23 '18 at 11:40
HabeebHabeeb
3,83211825
3,83211825
add a comment |
add a comment |
If I understood correctly you just need a new DateTime
object that takes the year from startDate
, but has fixed day and month? Then assuming that you have startDate
as a DateTime
object already you just do:
new DateTime(startDate.Year, financialYearEndMonth, financialYearEndDay)
add a comment |
If I understood correctly you just need a new DateTime
object that takes the year from startDate
, but has fixed day and month? Then assuming that you have startDate
as a DateTime
object already you just do:
new DateTime(startDate.Year, financialYearEndMonth, financialYearEndDay)
add a comment |
If I understood correctly you just need a new DateTime
object that takes the year from startDate
, but has fixed day and month? Then assuming that you have startDate
as a DateTime
object already you just do:
new DateTime(startDate.Year, financialYearEndMonth, financialYearEndDay)
If I understood correctly you just need a new DateTime
object that takes the year from startDate
, but has fixed day and month? Then assuming that you have startDate
as a DateTime
object already you just do:
new DateTime(startDate.Year, financialYearEndMonth, financialYearEndDay)
answered Nov 23 '18 at 11:41
KonamimanKonamiman
43.1k1598128
43.1k1598128
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445751%2fget-next-date-from-day-month%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
DateTime dateTime = new DateTime(Date.Now.AddYears(1).Year,financial year end date's month,financial year end date's day)
– ikerbera
Nov 23 '18 at 11:23
I have updated my question. How to do it with that?
– iDipa
Nov 23 '18 at 11:27
Do you have these strings as input ? You're going to have a bad time .. Maybe Humanizr has something on that but I doubt it. Deal with
DateTime
structure instead– Arthur Attout
Nov 23 '18 at 11:29
Same code,
Date.Now.AddYears(1).Year
takes todays date, adds a year and gives you the int for the year of the new calculated date. If you still have day and month in the same variables it should work.– ikerbera
Nov 23 '18 at 11:30
@iDipa, is your financial year end date is correct? please check it is not next year financial end date if start Date is = 23rd Nov 2019
– Prasad Telkikar
Nov 23 '18 at 11:30