All Questions
2,059
questions
2
votes
1
answer
136
views
Why is C# DateTime.Now/DateTime.UtcNow ahead of SQL Server's SYSUTCDATETIME()/SYSDATETIME() even though C# code executes before the SQL Query
I want to know the reason why my C# date is larger than the SQL date even though the C# code is running first and after that the SQL query,
Logically the SQL date should be greater than C# date.
For ...
2
votes
0
answers
58
views
Why is the DateTime with specified culture ´nl-NL´, written in culture that is set by the browser?
In Blazor Wasm, I use the following code to write today's date in LongDatePattern to the console. It works well for English, German, Spanish and French. But for Dutch, it writes the date in the ...
0
votes
0
answers
71
views
How to guard against DateTime code breaking on Azure
I recently ran into an issue with the following line of code Linq:
var directions = unitDirections.Directions
.Where(d => Convert.ToDateTime(d.DueDate) > DateTime.Today || (Convert.ToDateTime(d....
2
votes
2
answers
79
views
.NET difference in DateTIme parsing
I'm using .NET 8 and I noticed that DateTime strings from requests are parsed differently in the query parameters and in the body.
I have made this example request to show the issue:
POST /api/Save?...
0
votes
1
answer
60
views
How do I configure NodaTime Instant to LocalDateTime Serialization in ASP.NET Core 6.0 Web API
I can't figure out how to convert NodaTime's Instant datatype to LocalDateTime or even better to System.DateTime.
I can save Instant to a Postgresql database and then receive it via web service. Web ...
1
vote
0
answers
30
views
How can the system time and computer time be different locally in .net core API?
I am running a .net core API project locally on my Windows machine, local time is utc +3. In the response header returned from the requests, the results are returned according to utc + 0.
This time ...
1
vote
1
answer
127
views
How to strip off Timezone part from DateTime to leave only local DateTime part? (no string parsing or manipulations)
I have a similar question to this one: How to strip timezone from DateTime in .NET Core, but I don't want to use any string based parsings.
Basically I have events coming from various locations in the ...
0
votes
0
answers
41
views
After upgrading from .NET 5 to .NET 7 and removing Newtonsoft.Json, DateTime values in API responses are different [duplicate]
I recently upgraded my project from .NET 5 to .NET 7 and removed Newtonsoft.Json by replacing it with System.Text.Json. After the upgrade, I noticed that DateTime values in the responses of my API ...
0
votes
0
answers
125
views
How to find to find 'today at midnight' in .NET?
We have a cron job scheduled at 'every day 3pm paris,' 'every day 3pm new york,' etc
In our code, the logic is to find all transactions realized between midnight and noon in the specified timezone
...
1
vote
1
answer
44
views
algorithm for getting the not intersected intervals with another interval
Let us say I have a large interval
LargeInterval interval = new LargeInterval
{
StartPeriod = DateTime.Today,
EndPeriod = DateTime.Today.AddYears(1),
};
where
public class LargeInterval
{
...
3
votes
5
answers
306
views
How can I check if a DateTime lies between a certain date range without taking the year into account?
I'm cognitively struggling with a probably fairly simple problem. Given a certain DateTime, how can I verify that this date (without accounting its year) is in between two other dates?
An example:
...
0
votes
0
answers
73
views
Trying to convert DateTime + a timezone to DateTimeOffset of the local timezone
I'm trying to convert a hardcoded DateTime to a DateTimeOffset but localized to the provided timezone.
Given the hardcoded DateTime of: DateTime someUtcDateTime = new(2022, 1, 1, 12, 0, 0); and a ...
0
votes
1
answer
79
views
Parse a string with timezone offset into DateTime doesn't require conversion to UniversalTime
I have data in my SQL server database that is filtered based on date. I store the data in UTC time always. I have an API that accepts a From and To date filter to fetch these records.
I was facing ...
-2
votes
1
answer
126
views
Parsing "dd MMMM, yyyy" using DateTime.TryParseExact [closed]
I'm working with TryParseExact but it's throwing an error.
What could be the issue? Thanks
DateTime result;
if (DateTime.TryParseExact("31 December, 2023", ["'dd MMMM, yyyy'"],
...
0
votes
0
answers
41
views
How can one test if a property was set to DateTime.Now
I'm using NUnit to unittest a project. I have some code that creates an object and uses datetime.now to register the moment the object was created. This data can be very important, so it must be ...