Adding days to the Date portion of DateTime throws off the Time portionCalculate days between DateTime field...
Levi-Civita symbol: 3D matrix
Should I use HTTPS on a domain that will only be used for redirection?
Correct physics behind the colors on CD (compact disc)?
Are there other characters in the Star Wars universe who had damaged bodies and needed to wear an outfit like Darth Vader?
Deal the cards to the players
It doesn't matter the side you see it
How do we objectively assess if a dialogue sounds unnatural or cringy?
What is better: yes / no radio, or simple checkbox?
PTIJ: Why can't I sing about soda on certain days?
Sometimes a banana is just a banana
How can neutral atoms have exactly zero electric field when there is a difference in the positions of the charges?
3.5% Interest Student Loan or use all of my savings on Tuition?
Plagiarism of code by other PhD student
“I had a flat in the centre of town, but I didn’t like living there, so …”
Can a Trickery Domain cleric cast a spell through the Invoke Duplicity clone while inside a Forcecage?
How can I conditionally format my HTML table?
The need of reserving one's ability in job interviews
Why do phishing e-mails use faked e-mail addresses instead of the real one?
Split a number into equal parts given the number of parts
Where is this quote about overcoming the impossible said in "Interstellar"?
Why is it "take a leak?"
Relationship between the symmetry number of a molecule as used in rotational spectroscopy and point group
A bug in Excel? Conditional formatting for marking duplicates also highlights unique value
Find maximum of the output from reduce
Adding days to the Date portion of DateTime throws off the Time portion
Calculate days between DateTime field and Now()Combine Date from one datetime field with Time from anotherAdding a time to datetimedifference between two date time fields in daysConvert String DateTime to User Locale Date TimeNew Datetime instance on Daylight Savings Time transition date?Time portion of Datetime formula field inconsistentParse date time string to Apex DateTimeConsume Date/time Iso 8601 timestamp in salesforce Datetime fieldAdding days and then business days to a datetime field
So I'm having an issue in Apex with the Date's addDays function. It seems that adding more than a certain amount of days throws off the time by one hour. It all seems so arbitrary so I'm wondering if this is a known thing in Salesforce or not.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(4), aDate.time());
System.debug(adjustedDate);
Running that in an execute anonymous box outputs the following:
2019-03-05 17:44:28
2019-03-09 17:44:28
That's all good. The same date separated by four days and the same time. Just as you'd expect. But... adding five or more days causes behavior I can't wrap my head around.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(5), aDate.time());
System.debug(adjustedDate);
This outputs the following:
2019-03-05 17:46:08
2019-03-10 16:46:08
It falls back by an hour. Any idea why or is this a known thing? I'm in central timezone so my time is actually -6 hours from the printed time.
apex datetime bug
New contributor
add a comment |
So I'm having an issue in Apex with the Date's addDays function. It seems that adding more than a certain amount of days throws off the time by one hour. It all seems so arbitrary so I'm wondering if this is a known thing in Salesforce or not.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(4), aDate.time());
System.debug(adjustedDate);
Running that in an execute anonymous box outputs the following:
2019-03-05 17:44:28
2019-03-09 17:44:28
That's all good. The same date separated by four days and the same time. Just as you'd expect. But... adding five or more days causes behavior I can't wrap my head around.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(5), aDate.time());
System.debug(adjustedDate);
This outputs the following:
2019-03-05 17:46:08
2019-03-10 16:46:08
It falls back by an hour. Any idea why or is this a known thing? I'm in central timezone so my time is actually -6 hours from the printed time.
apex datetime bug
New contributor
add a comment |
So I'm having an issue in Apex with the Date's addDays function. It seems that adding more than a certain amount of days throws off the time by one hour. It all seems so arbitrary so I'm wondering if this is a known thing in Salesforce or not.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(4), aDate.time());
System.debug(adjustedDate);
Running that in an execute anonymous box outputs the following:
2019-03-05 17:44:28
2019-03-09 17:44:28
That's all good. The same date separated by four days and the same time. Just as you'd expect. But... adding five or more days causes behavior I can't wrap my head around.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(5), aDate.time());
System.debug(adjustedDate);
This outputs the following:
2019-03-05 17:46:08
2019-03-10 16:46:08
It falls back by an hour. Any idea why or is this a known thing? I'm in central timezone so my time is actually -6 hours from the printed time.
apex datetime bug
New contributor
So I'm having an issue in Apex with the Date's addDays function. It seems that adding more than a certain amount of days throws off the time by one hour. It all seems so arbitrary so I'm wondering if this is a known thing in Salesforce or not.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(4), aDate.time());
System.debug(adjustedDate);
Running that in an execute anonymous box outputs the following:
2019-03-05 17:44:28
2019-03-09 17:44:28
That's all good. The same date separated by four days and the same time. Just as you'd expect. But... adding five or more days causes behavior I can't wrap my head around.
DateTime aDate = System.now();
System.debug(aDate);
DateTime adjustedDate =
DateTime.newInstance(aDate.date().addDays(5), aDate.time());
System.debug(adjustedDate);
This outputs the following:
2019-03-05 17:46:08
2019-03-10 16:46:08
It falls back by an hour. Any idea why or is this a known thing? I'm in central timezone so my time is actually -6 hours from the printed time.
apex datetime bug
apex datetime bug
New contributor
New contributor
New contributor
asked yesterday
DylanDylan
183
183
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Daylight saving time 2019 in central timezone will begin at
2:00 AM on
Sunday, March 10
and ends at
2:00 AM on
Sunday, November 3
All times are in Central Time.
:)
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "459"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
Dylan is a new contributor. Be nice, and check out our Code of Conduct.
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%2fsalesforce.stackexchange.com%2fquestions%2f252620%2fadding-days-to-the-date-portion-of-datetime-throws-off-the-time-portion%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Daylight saving time 2019 in central timezone will begin at
2:00 AM on
Sunday, March 10
and ends at
2:00 AM on
Sunday, November 3
All times are in Central Time.
:)
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
add a comment |
Daylight saving time 2019 in central timezone will begin at
2:00 AM on
Sunday, March 10
and ends at
2:00 AM on
Sunday, November 3
All times are in Central Time.
:)
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
add a comment |
Daylight saving time 2019 in central timezone will begin at
2:00 AM on
Sunday, March 10
and ends at
2:00 AM on
Sunday, November 3
All times are in Central Time.
:)
Daylight saving time 2019 in central timezone will begin at
2:00 AM on
Sunday, March 10
and ends at
2:00 AM on
Sunday, November 3
All times are in Central Time.
:)
answered yesterday
Aayush KAayush K
1,11247
1,11247
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
add a comment |
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
In other words, Daylight Saving Time begins in 5 days at this point in time. Which explains the discrepancy between adding 4 days and 5 days.
– Derek F
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
Wow. I completely forgot about Daylight savings time. Thank you!
– Dylan
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
+1. Great observation on Daylight changes.
– Jayant Das
yesterday
add a comment |
Dylan is a new contributor. Be nice, and check out our Code of Conduct.
Dylan is a new contributor. Be nice, and check out our Code of Conduct.
Dylan is a new contributor. Be nice, and check out our Code of Conduct.
Dylan is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Salesforce Stack Exchange!
- 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%2fsalesforce.stackexchange.com%2fquestions%2f252620%2fadding-days-to-the-date-portion-of-datetime-throws-off-the-time-portion%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