Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
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 ...
Shivam's user avatar
  • 29
-2 votes
3 answers
56 views

Numeric string to datetime conversion in C# Winforms application

I'm getting a date value from XML in string (numeric). I want to convert the value like 72124 to 7/21/2024. Then further I have to assign 7/21/2024 to a string variable. Please help
Sarthak Mishra's user avatar
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 ...
Flippowitsch's user avatar
1 vote
1 answer
28 views

.NET c#: Convert string (ej. "Mar 26, 2021 at 7:17 PM") to DateTime object

I am trying to create a DateTime object from strings like Dec 1, 2020 at 11:03 AM Mar 26, 2021 at 7:17 PM Oct 21, 2020 at 3:07 PM I am using this but it throws error: string format = "MMM d, ...
patsy2k's user avatar
  • 551
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....
Norbert Norbertson's user avatar
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?...
Ben5's user avatar
  • 787
0 votes
1 answer
53 views

Changing internal storage of DateTime property? [duplicate]

I'm wanting to store the clock in and clockout properties in dd-mm-yyyy hh-mm but dont want anything else stored. Is this possible to do? public class TimeCard { public int Id { get; set; }...
molly1312's user avatar
0 votes
0 answers
55 views

MongoDB Date Conversion Problem for "London/Europe" TimeZone in Azure Function C#

In my Azure Function, I configured environment variable WEBSITE_TIME_ZONE as Europe/London, hosted this on Azure Linux App Service Plan with "North Europe Zone" and in my base class, I ...
Unknown Coder's user avatar
0 votes
1 answer
47 views

DateTimeOffset Ticks is bugged or not? [closed]

I used a sorted list like that: SortedList<DateTimeOffset, Something>. The data is well sorted according to the UTC date-time, which is expected. But "Ticks" is bigger (for DST - for ...
Eric Ouellet's user avatar
  • 11.5k
1 vote
1 answer
60 views

DateTime ParseExact throws FormatException for only PM times

I have a list of different DateTime formats and I want to convert all of them in one specific format. It works fine, until I hit this line: 9.13.2023 2:06:58 PM. On this line i get an System....
SpleX's user avatar
  • 15
0 votes
0 answers
83 views

Validating a valid DateTime Format in C#

I'm currently working on validating various DateTime formats provided manually by users to ensure their validity within my application. My current approach involves converting a sample DateTime object ...
ALTHAF ABDUL SALAM's user avatar
0 votes
1 answer
28 views

C# setting or update only the timezone value, not converting

I am constructing a new C# DateTime from int values for year, month, day, hours, minutes & seconds. The values are already adjusted for the destination timezone. (I cannot change that. I am given ...
Tolga Köseoğlu's user avatar
0 votes
0 answers
41 views

.NET build predicate with custom date format (not using client side). LinqKit

I don't know if this is possible. I've been trying to implement a "global filter" that runs a "like" clause on the database engine and it varies a little bit depending on the ...
Alex Ibrahim Ojea's user avatar
1 vote
1 answer
74 views

How to subtract 1 day when using Datetime

I am attempting to get the number of orders from the last 24 hours from a third party system. I havent used DatetimeOffset before so eventually figured out how to subtract 1 day from the current day. ...
KeithViking's user avatar
0 votes
1 answer
54 views

C# specify kind on date

I am trying to work on getting data based on start and end date but I keep getting an error each time, this is what I have var startDateTime = DateTime.SpecifyKind(StartDate.Value.ToDateTime(TimeOnly....
Stephen OHAERI's user avatar

15 30 50 per page
1
2 3 4 5
692