Тёмный

Date and Time in C# 10 and .NET 6 In 10 Minutes or Less 

IAmTimCorey
Подписаться 421 тыс.
Просмотров 83 тыс.
50% 1

In C# 10, we now have the DateOnly and TimeOnly types instead of just DateTime. See how to use them in this 10-Minute Training video.
Full Courses: iamtimcorey.com
Source Code: leadmagnets.ap...
Mailing List: signup.iamtimc...

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 283   
@khue681
@khue681 2 года назад
I like this format of focusing on a topic for 10 mins or less. It's easier to consume for me. Nice job!
@IAmTimCorey
@IAmTimCorey 2 года назад
I'm glad it is helpful. Just remember to practice what you see so you can actually learn the topic.
@turn1210
@turn1210 2 года назад
Agreed, this is a great idea
@ArkamitDutta
@ArkamitDutta 2 года назад
@@IAmTimCorey This sort of mini tutorials will come very handy while quickly searching for something or recalling something. Keep up the good work!!
@e.h.5680
@e.h.5680 2 года назад
@@IAmTimCorey You won't believe how many of your videos I haven't seen - but wants to see - because I can't spend half an hour on a video 😁
@sergeyt4118
@sergeyt4118 2 года назад
@@IAmTimCorey thanks a lot, this is very useful; like this new compact format, it is convenient and allows to digest info in an effective way
@TedwardUltimate
@TedwardUltimate 2 года назад
I guess you could say that the “10 minutes or less” format helped me save a lot of TimeOnly 😉
@IAmTimCorey
@IAmTimCorey 2 года назад
Excellent!
@shmupful
@shmupful 2 года назад
I really like the 10 min. concept, I think it's a great addition to this wonderful channel, keep up the good work Tim!
@IAmTimCorey
@IAmTimCorey 2 года назад
I’m glad.
@muhamedkarajic
@muhamedkarajic 2 года назад
I think the same, New to the channel, I wanted to check some other videos of you but don't find the TimeOnly... muhahhahah lol
@muhamedkarajic
@muhamedkarajic 2 года назад
I think the same, New to the channel, I wanted to check some other videos of you but don't find the TimeOnly... muhahhahah lol
@tuppas
@tuppas 2 года назад
This 10 minute series make a huge difference. Thank you Tim
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@godwinyoh3700
@godwinyoh3700 2 года назад
this is much better, will help a lot with date/time comparisons without worrying about an the time
@warrenbuckley3267
@warrenbuckley3267 2 года назад
I feel like they should have added a static "Now" property to both the DateOnly and TimeOnly structs.
@IAmTimCorey
@IAmTimCorey 2 года назад
Yeah, I would have liked that too.
@ValentineMasina
@ValentineMasina 2 года назад
Lovely explanation. Currently enrolled for C# Foundation series. Keep them coming Tim. Also appreciate the 10 minute format videos like others have said.
@IAmTimCorey
@IAmTimCorey 2 года назад
Thank you!
@Rhodair
@Rhodair 2 года назад
These seem like a long awaited addition, not something I may use too often myself, but I could see this becoming far nicer for code-to-database scenarios utilizing down the line
@IAmTimCorey
@IAmTimCorey 2 года назад
I agree.
@t0fy82
@t0fy82 2 года назад
Loving these 10 minute guides, Thank you Tim!!
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@oxynetz
@oxynetz 2 года назад
This is what I've been looking for. Thanks.
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@henrydev95
@henrydev95 2 года назад
Actually, I really like these 10 minutes series. Watching a long video is difficult to me. Nice :)
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@lborate3543
@lborate3543 2 года назад
What I learned from this video: Tim, you need to go to bed earlier! It’s 11:45pm bro, get some sleep! Lol
@IAmTimCorey
@IAmTimCorey 2 года назад
It is my best time to record. The house is quiet. I’m building a studio to make this better.
@otkirbeksobirjonov9695
@otkirbeksobirjonov9695 2 года назад
It's very nice. Thanks for you
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@aishwaryashiva1906
@aishwaryashiva1906 2 года назад
I just love this feature 😍😍😍 waiting for this since I first learned DateTime in C# ❤️
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@titusxp
@titusxp 2 года назад
Long overdue. I built an app once that stores the time employees are supposed to come to work each day. It was hellish working with dateTime
@IAmTimCorey
@IAmTimCorey 2 года назад
Yeah, that’s not fun.
@adoreyourpain
@adoreyourpain 2 года назад
Just made an appointment manager and my gosh was working with DateTime the most frustrating thing ever.
@zwatotem
@zwatotem 2 года назад
Good format. Consider using C# interactive for these quick demos, that way you can present inputs and outputs in one window, without popups.
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks for the suggestion.
@mb-ql1gb
@mb-ql1gb 2 года назад
Response: I really like this 10 minute short "on point" tutorials .... Great move!
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks!
@normthethird
@normthethird 2 года назад
I agree with everyone in that concepts of 10 min or less is a good strategy. Thanks for all you do!
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@ericwagner2307
@ericwagner2307 2 года назад
Thank you! And going hard at 11:43pm, we see you
@IAmTimCorey
@IAmTimCorey 2 года назад
Yep. That’s the best recording time for me right now. I’m building a recording studio so that I can record during the day. I’m hoping to have that up and running next month.
@ericwagner2307
@ericwagner2307 2 года назад
@@IAmTimCorey that is amazing news, I hope you continue to grow and share your knowledge with us. Congrats on the studio, we hope to get you back to day hours soon 😎
@TheOnlyDominik
@TheOnlyDominik 2 года назад
Reduce the time to 1 Minute for such a simple thing. Thank you. ;-)
@IAmTimCorey
@IAmTimCorey 2 года назад
Sorry, no. If you want that type of content, just read the docs. The problem is that you don't get the context. That's what I provide.
@torgeirullestad3921
@torgeirullestad3921 Год назад
So used to having to write TheDate = DateTime.Now.ToString("dd.MM.yyyy") and TheTime = DateTime.Now.ToString("HH:mm:ss"). Glad things have improved over the years.
@IAmTimCorey
@IAmTimCorey Год назад
Glad you will find them valuable.
@myinterests3934
@myinterests3934 2 года назад
it take 21 years for Microsoft to come to this solution which was very simple from the beginning itself. Even here there was no need for only in those data types. Date is just date no need to tell DateOnly when the other alternative is already DateTime.
@IAmTimCorey
@IAmTimCorey 2 года назад
The problem is that we always see others' problems as easy and our own as difficult. In this case, if they left off the only, they would have caused problems for literally hundreds of thousands of people. It isn't a "simple" problem. It was a complex situation brought on by a desire not to make breaking changes. They made a hard decision with few good options.
@sharatha6533
@sharatha6533 2 года назад
Hey Tim. Thanks for the video and I liked the new option for date. But question is how does it work if we use this in EF Core Entity model with Code First approach. Thanks in advance
@haroldpepete
@haroldpepete 2 года назад
I love that feature too
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@Chess_Improvement
@Chess_Improvement 2 года назад
thanks, more about features
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@s.n.3867
@s.n.3867 2 года назад
Great video, new Time raises with C#10 I guess. How this compares with DateTimeOffset where you also not getting rollovers due to date offset stored? Is this not solving the issue already, or is there a missconceotion on my side?
@camlcase
@camlcase 2 года назад
Thank you Tim! Love the ~10 min format.
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@delw1138
@delw1138 2 года назад
I like these, I wonder about saving them to a data source though.
@IAmTimCorey
@IAmTimCorey 2 года назад
It is going to take some time for the data connectors to properly handle these new types.
@titusxp
@titusxp 2 года назад
Good point m exactly what I thought of as i watched the video.
@brian_pos
@brian_pos 2 года назад
I also like the 10 minute format as many others here have commented. Would also have liked to see the DateTimeOffset also mentioned quicly too (as it also appeared in the intelisense at one point - especially when you also mentioned the timezone handling stuff - that the DateTimeOffset handles far better than just DateTime. Once again, a great little snippit.
@IAmTimCorey
@IAmTimCorey 2 года назад
Glad you like it and thanks for the suggestion.
@terminatorx7817
@terminatorx7817 2 года назад
thanks so much.
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@otkirbeksobirjonov9695
@otkirbeksobirjonov9695 2 года назад
Teacher can you introduce us about Clean architecture
@IAmTimCorey
@IAmTimCorey 2 года назад
It is on the suggestion list.
@ferrarijuan
@ferrarijuan 2 года назад
Awesome, this was a long time coming! Finally we won't need to write unnecessary code and use up resources because we just wanted the "dateOnly" or "timeOnly" in our code. I don't know about the rest of the community, but we sure use dates a lot in our software, so this is going to help a lot. I also love the format of the 10 minute video, but I do feel that the longer, more in depth discussions, are still needed for those topics that you would not be able to explain in 10 minutes or less.
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks for the feedback. The Monday videos are still going to be the long-format training.
@niangel2704
@niangel2704 2 года назад
Wouldn't be better if the DateOnly property of a model could be translated to sql by the fluent api?! Nice 10min format!! Congratulations Tim and thanks a million for helping us
@mohammadaminyaghoubzadeh7792
@mohammadaminyaghoubzadeh7792 2 года назад
I love this
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@chezchezchezchez
@chezchezchezchez 2 года назад
would’ve been nice to see some old code Refactored this new way to show the clarity benefit.
@IAmTimCorey
@IAmTimCorey 2 года назад
That's more of a full Monday video format rather than a 10-minute video format. I will be covering DateTime (and these new ones) in a future Monday video.
@davidiverson
@davidiverson 2 года назад
Awesome feature, there are lots of instances for me where I only want the time or the date. Thanks for putting this into the 10 minute format. Perfect amount of explanation.
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@CodingJesus
@CodingJesus 2 года назад
Why not just do DateTime date = DateTime.Now.Date?
@IAmTimCorey
@IAmTimCorey 2 года назад
That is still a DateTime object (so 10/23/2021 12:00:00) rather than just the date (10/23/2021).
@christopherserrao4566
@christopherserrao4566 2 года назад
TimeOnly should've supported timezones
@nurullahkaratas4120
@nurullahkaratas4120 2 года назад
Hey Tim. Good te see 10 minutes series. Good idea.
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks!
@nurullahkaratas4120
@nurullahkaratas4120 2 года назад
@@IAmTimCorey Is this an automatic reply :). You are great in relation with your watchers. Cool for you.
@IAmTimCorey
@IAmTimCorey 2 года назад
Nope. I don’t have automatic replies.
@bbry323
@bbry323 2 года назад
DateTimeOffset? I’m not sure how to best implement this
@webluke
@webluke 2 года назад
A great short video on little topics or changes to keep people up to date. It seems like they could have just broken up more methods to the DateTime object to show dates or times, but it gives other options.
@IAmTimCorey
@IAmTimCorey 2 года назад
They didn’t want to mess with the existing because they wanted to keep compatibility and they wanted to keep the objects small.
@DevMeloy
@DevMeloy 2 года назад
Dealing with date and time is a pain in most languages.. so this is always welcome! Not the same thing but C# has had other date'ish objects like TimeSpan.
@IAmTimCorey
@IAmTimCorey 2 года назад
Yep, I agree.
@sergejssehonins7629
@sergejssehonins7629 2 года назад
I like short video like this. Some time you need just to get some info.
@fuzzy0001
@fuzzy0001 2 года назад
Can we use these in our EF entities?
@dimitrigunsing1760
@dimitrigunsing1760 2 года назад
Isn't this just another way of writing DateTime.Now.Date and DateTime.Now.TimeofDay? Are these new objects more memory efficient?
@IAmTimCorey
@IAmTimCorey 2 года назад
Nope. Those properties still give you a DateTime but with the "irrelevant" part at the default (so 10/21/2021 12:00:00 for the date). These new objects are just the date or just the time. Yes, it is more efficient.
@rodolfoiiiperez4291
@rodolfoiiiperez4291 2 года назад
nice short video. More informative video sir.
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 2 года назад
Be sure to check out his complete playlist of short 10 minute videos - ru-vid.com/group/PLLWMQd6PeGY1MtyfNc0RbJSrC9LRUmT-6
@JoeLizFamily4
@JoeLizFamily4 2 года назад
Useful but need to be careful as it cannot be converted to UTC to compare with other DateOnly and TimeOnly objects. Example: you said the TimeOnly can be used to show the open and close times of a store. What if someone from a different time zone wanted to know if your store was open right now so they could call to place an order. The website might be misleading showing it was open when it was closed and vice versa. In some ways this feels like a throwback to the way things were done in older languages.
@IAmTimCorey
@IAmTimCorey 2 года назад
Think of this more like the writing on the door for the hours rather than the times on Google. But even the times on Google take into account the time zone of the location. You don't need the time zone on each time if you know what time zone the store is physically located in.
@IfratMitul
@IfratMitul 2 года назад
Finally they added it, i hated the DateTime type in .NET
@galberts
@galberts 2 года назад
I'd like se how to work with timezones in Blazor: displaying the date in the timezone of the client, editing the date and sending the date back to the server. With normal dates, but also with DateOnly and TimeOnly.
@IAmTimCorey
@IAmTimCorey 2 года назад
If you are dealing with time zones, you probably want the DateTime object.
@AnaRxistBoD
@AnaRxistBoD 2 года назад
The main question is that how does this look like 'under the facade'? Do DateOnly and TimeOnly have their separate implementation that is not depending on DateTime class? Because if not than it's just some heavy syntax sugar thing going on there=))
@IAmTimCorey
@IAmTimCorey 2 года назад
I do not believe they rely on DateTime.
@MikeLyncheski
@MikeLyncheski 2 года назад
But seriously what good are these types without out-of-the-box JSON and EF SQL Server support? Looks like we have to wait until Dot Net Core 7 for this.
@IAmTimCorey
@IAmTimCorey 2 года назад
Change like this takes time. These led the way so that not just the Microsoft teams could use them, but also third-partly libraries could as well.
@rodcka
@rodcka 2 года назад
Can I use this new types to map an entity propperty to database field use EntityFramewokr ? Wondering how will entity framework handle these types against a database.
@IAmTimCorey
@IAmTimCorey 2 года назад
I don't think so yet, but support is coming.
@coachnico8041
@coachnico8041 2 года назад
Thanks for the video. Leave it to the .Net team to add unnecessary words to an object name. I thought maybe there's Date and Time aliases or something, but nope.
@IAmTimCorey
@IAmTimCorey 2 года назад
I covered that in the video - there is a Date alias in VB that would have caused a conflict. There is also the property off of DateTime called Date that returns a DateTime at midnight that would have been confusing.
@henry770
@henry770 2 года назад
I think this is probably only useful for weird edge cases, if at all. All the benefits for string conversions can also be gained from just learning the relevant formatting symbols. The “weird rollovers” are important because they are telling you something true about that moment in time. To pretend time zones simply don’t exist will lead to more user confusion.
@IAmTimCorey
@IAmTimCorey 2 года назад
I don't think it is that limited. Think store hours. When you post store hours in the window, you don't include time zones. It is a physical location, so the time will be in that location's time zone. The same is true for birthdays. I don't specify a time for my birthday, just a date. I don't specify which time zone that birthday is in either. Christmas is on December 25th. There are a lot of dates and times that do not relate to a specific time and date in a specific location. They aren't the majority, but there are a lot of them and so far, we have been working around them by specifying date or time parts that are ignored.
@henry770
@henry770 2 года назад
@@IAmTimCorey Fair, but those examples are typically just for the purposes of display, no? The moment you try to do any work (math) with them is where you can run into trouble. In my day job role, I set the standards for the developers, and I build a time tracking app that is used by geographically distributed teams on the side. Because I've seen far more than my fair share of temporal arithmetic problems and I spend a lot of time trying to cordon off pitfalls for others, I may be overreacting here. I have been annoyed multiple times by having to deal with DateTime & TimeSpan when it comes to things like binding to UI controls, etc., so I can see why this kind of thing is exciting. I'm just concerned that some folks might see this as an upgrade that resolves the weird things they sometimes see because of timezones, leaps, etc. and not know they're really just sweeping them under the rug.
@m0n3ysh0t
@m0n3ysh0t 2 года назад
Very nice. Thanks Tim!
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@cakdham4607
@cakdham4607 2 года назад
Hi tim, thanks for everything.. do you have topic about naming convention.. I think it's very basic important
@IAmTimCorey
@IAmTimCorey 2 года назад
I don't but that sounds like a good video suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@teisdraiby9386
@teisdraiby9386 Год назад
The DateTime object doesn’t contain time zone information either (as you could believe from the video). DateTimeOffset is the object of choice to store the time zone along with the DateTime as DateTime is limited to specifying whether is is considered local (the computer’s time zone), UTC or unknown.
@JohnPeter-yf5jf
@JohnPeter-yf5jf Месяц назад
Nice to find what I’m looking for from Tim. Always the first watch
@IAmTimCorey
@IAmTimCorey Месяц назад
Great!
@pointlesspos8440
@pointlesspos8440 2 года назад
How about working with international formats, and storing that data. Then working with both the US and International formats at the same time.
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks for the suggestion. Please add it to the list on the suggestion site so others can vote on it as well: suggestions.iamtimcorey.com/
@brad_mcallister
@brad_mcallister 2 года назад
Thrilling stuff.... How in earth did you make that last 7 minutes.
@IAmTimCorey
@IAmTimCorey 2 года назад
Not sure what you mean.
@andywalter7426
@andywalter7426 2 года назад
The DateOnly is so good that I decided to redo my custom blazor calendar control to use dateonly instead of datetime since using a calendar is intended to choose date but not time.
@IAmTimCorey
@IAmTimCorey 2 года назад
Sounds like a good use.
@مارياأحمد-ش5ط7ر
@مارياأحمد-ش5ط7ر 2 года назад
What is an edite undo library?
@stephajn
@stephajn 2 года назад
Can you do a video showing DateTimeOffset and how to work with time zones?
@IAmTimCorey
@IAmTimCorey 2 года назад
I'll add it to the suggestion list.
@jyotirmoymaschatak2599
@jyotirmoymaschatak2599 2 года назад
Thanks Tim!!
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@sandrorosso2165
@sandrorosso2165 2 года назад
Lol this videos comes out while i'm working on a project that uses a javascript calendar in Blazor, so I need to pass dates between js and .net. Dates are so fun, even more parsing them back and forth lol i need help
@IAmTimCorey
@IAmTimCorey 2 года назад
I’ll be doing a larger video that covers all of DateTime soon. Maybe that will help.
@sandrorosso2165
@sandrorosso2165 2 года назад
@@IAmTimCorey thank you a lot!
@TobiasKrasinger
@TobiasKrasinger 2 года назад
So is this a C# 10 Feature or just new DataTypes/Classes added in .net 6? Which relation has this to C# 10?
@IAmTimCorey
@IAmTimCorey 2 года назад
This is a C# 10 feature. C# 10 only works in .NET 6+.
@TobiasKrasinger
@TobiasKrasinger 2 года назад
@@IAmTimCorey Yes C#10 only works with .Net 6, but how can this be a new "language feature"? There is nothing new in the language for that, its just new datatypes added in .net 6. There is no new keyword or language feature to learn for using this. I'd say its just a .net 6 feature - and yes you will have to use C# 10 for this, but its not a language feature.
@user-kt7nd6pg1p3
@user-kt7nd6pg1p3 Год назад
I like this series. Please go to some advanced topics
@IAmTimCorey
@IAmTimCorey Год назад
Advanced topics typically cannot be covered in 10 minutes or less.
@bhatsanket
@bhatsanket 2 года назад
Love this...
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@MichaelBeck_profile
@MichaelBeck_profile Год назад
Is this anything useful for entity framework? How would properties with these types map?
@IAmTimCorey
@IAmTimCorey Год назад
Last I heard they were working on implementing these in EF, but I'm not sure if they have completed that work or not.
@MichaelBeck_profile
@MichaelBeck_profile Год назад
@@IAmTimCorey thank you!
@everyonesview
@everyonesview 2 года назад
Is it not easier to do new Datetime().Now.Date for Date only?
@IAmTimCorey
@IAmTimCorey 2 года назад
That doesn't produce a DateOnly. It produces a DateTime with a time of 12:00:00 (midnight).
@timlong7289
@timlong7289 2 года назад
I've always just used NodaTime because the built in DateTime classes make no sense except in the most trivial of cases. Microsoft should just deprecate those classes and start again from scratch in my opinion. Conflicts between object names should have been handled with namespaces.
@IAmTimCorey
@IAmTimCorey 2 года назад
Deprecating doesn’t mean the names go away and removing the names would break TONS of applications. A namespace “fix” would be tricky because we would have to change the default namespaces to exclude the old ones.
@timlong7289
@timlong7289 2 года назад
@@IAmTimCorey I fully understand what deprecating means, and that's exactly what I meant. You have to keep them around but marking them as [Obsolete] sends a strong message. Now create a new namespace and make a sensible date-time library that actually works well and doesn't have some funky semantics.
@IAmTimCorey
@IAmTimCorey 2 года назад
It isn't that simple. If you put them in a different namespace, you would have to reference them manually (so it would be NewDate.Date and NewDate.Time or whatever namespace you called them). Otherwise, they would conflict with the existing names in System.
@Osamah001
@Osamah001 2 года назад
How can you use Arabic calender Hijri?
@IAmTimCorey
@IAmTimCorey 2 года назад
I'm sorry, I am not familiar with that system, so I do not know how it would relate to this.
@IAmIndraTheGod
@IAmIndraTheGod 2 года назад
Why were these not called just Date and Time instead of DateOnly and TimeOnly
@IAmTimCorey
@IAmTimCorey 2 года назад
I covered that in the video, I believe. VB already had a Date type. They couldn't override that type because it would cause a difference in behavior, which would break backward compatibility.
@IAmIndraTheGod
@IAmIndraTheGod 2 года назад
Got it, thanks. I missed that part
@davidpinedosolano8916
@davidpinedosolano8916 2 года назад
could you transform a DateOnly + TimeOnly in a Datetime?, i say because theres sometimes for example when you have a picker for dates and other for hours, you save them in this DateOnly and TimeOnly but you need the DateTime for googlecalendar or any other calendar. Or maybe you want to do some operations with the hours or date and after that get the new datetime.
@IAmTimCorey
@IAmTimCorey 2 года назад
Yes, you can combine a DateOnly and TimeOnly into a DateTime.
@jcmorin2007
@jcmorin2007 2 года назад
11:40 PM, you work pretty late!
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 2 года назад
You have no idea the hours upon hours he puts into these videos for folks. We have to prod him to step away sometimes.
@tosinakinyemi3948
@tosinakinyemi3948 2 года назад
Thank's Tim. very helpful
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@rey6253
@rey6253 2 года назад
Finally sth to represent a birthday :p :p
@IAmTimCorey
@IAmTimCorey 2 года назад
Yep.
@MarkPearsonmrp
@MarkPearsonmrp 2 года назад
Been waiting for this for 20 years!!
@IAmTimCorey
@IAmTimCorey 2 года назад
Better late than never.
@jasoncox7244
@jasoncox7244 2 года назад
Will this mean that EntityFramework will now parse SQL DATE and TIME into these rather than a getting confused when a DateTime object translates back into a SQL DATE?
@IAmTimCorey
@IAmTimCorey 2 года назад
Not yet, but they are looking into it.
@joff3
@joff3 2 года назад
This is great, not something need all the time but I definitely have use cases when I only need the date or the time only. Will EF Core support the mapping to a date/time column?
@IAmTimCorey
@IAmTimCorey 2 года назад
Eventually but not yet.
@chris.catignani
@chris.catignani 2 года назад
Love the new DateOnly and TimeOnly.
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@muhamedkarajic
@muhamedkarajic 2 года назад
I still think its terrible name DateOnly I rather would have had Date.
@IAmTimCorey
@IAmTimCorey 2 года назад
Sure, but that wasn’t an option.
@muhamedkarajic
@muhamedkarajic 2 года назад
@@IAmTimCorey I know, and I know you explained it. It's just I wanna be that guy to who you will replay :D
@WillEhrendreich
@WillEhrendreich 2 года назад
oh, man.. I'm really gonna need the source code for this one.. not like that async await stuff, that's so obvious it's self evident.. but this. man.. I just don't know.. even with source code, will any of us understand? lol. :) Seriously though, thanks again for a great explanation, Tim!
@IAmTimCorey
@IAmTimCorey 2 года назад
lol yeah, not exactly huge code but some people will want it.
@CoderboyPB
@CoderboyPB 2 года назад
Hi Tim, at 0:33 the Tab Tab to accept, is that an extension or a feature of the new VS?
@IAmTimCorey
@IAmTimCorey 2 года назад
That’s a new feature of VS2022.
@CoderboyPB
@CoderboyPB 2 года назад
@@IAmTimCorey Nice, must have it. Time for the release 😃
2 года назад
I think this feature is a very nice one!
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@norbertcsibi7720
@norbertcsibi7720 2 года назад
You`re a star! Keep up the good tuts :)
@IAmTimCorey
@IAmTimCorey 2 года назад
Thank you!
@DOSdaze
@DOSdaze 2 года назад
I work with a lot of databases that have separate date and time columns. Will be nice to have more specific datatypes to use on the CLR side of things.
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@dand4485
@dand4485 2 года назад
This looks great, really curious how it integrates with SQL/SQLClient, many times when needing to deal with dates/dateTimes we will find out in certain use cases there will be issues. You look at what MS provides and think great this should be really nice, only to find out later what seems logical for how things should work then won't in some edge cases. I'm certain we will see some issues around edges cases when interacting with the different SQL's DateTime column types, code i've had before would have issues depending on the underlying DateTime for the column definition itself, but more the interaction between Sql, ADO.Net and Entity Framework. Would suggest make you test this good...
@IAmTimCorey
@IAmTimCorey 2 года назад
So far it isn't integrated yet. That is coming.
@Luis-ef2zn
@Luis-ef2zn 2 года назад
Whats the difference between this and TimeSpan
@IAmTimCorey
@IAmTimCorey 2 года назад
TimeOnly is a set point in time (3:21pm). TimeSpan is a length of time (4 hours 2 minutes).
@MiningForPies
@MiningForPies 2 года назад
I’ve been wanting this feature for 20 years.
@IAmTimCorey
@IAmTimCorey 2 года назад
Better late than never, I guess.
@MiningForPies
@MiningForPies 2 года назад
@@IAmTimCorey just in time for a major rewrite of our systems 😁
@zithfrg
@zithfrg 2 года назад
Finally! It only took like 20 years for Microsoft to do it! Almost no time at all! 😂. Buy seriously, I have been wanting this since the first day I started programming!!!!!!!
@IAmTimCorey
@IAmTimCorey 2 года назад
Yeah, it has been a long time in coming but I’m glad it is here.
@williammain3247
@williammain3247 2 года назад
Thank you very much for the content and this new-to-me shorter video style. As a paid RU-vid Member, I really appreciate not having “paid promotions” in your videos to include an overview of your channel. If you could at least embed a “skip intro” to quickly get past the channel overview I would like it.
@IAmTimCorey
@IAmTimCorey 2 года назад
Thanks for the suggestion.
@mcintoshdev
@mcintoshdev 2 года назад
I think where this is gonna really be useful is when we're presenting or displaying what dates and times are. I think from a calculation standpoint I would probably keep using DateTime. Thanks for showing this!
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@jacquesdemolay2699
@jacquesdemolay2699 Год назад
What is wrong with using: string fullDate = DateTime.Now.ToString() or whatever suitable string method string dateOnly = fullDate.Split( new char { ' ' }, StringSplitOptions.None )[0]; string timeOnly = fullDate.Split( new char { ' ' }, StringSplitOptions.None )[1]; in this way you have timeZones accounted for and how about wrapping all this into a string Extension accessible from fullDate (just to keep date and time linked to same value of DateTime.Now) - and add 2 functions called GetDateOnly() and GetTimeOnly() or whatever meaningful names.
@rockymarquiss8327
@rockymarquiss8327 2 года назад
I'll use it quite a bit. The times I used timestamps is in the database - I put a timestamp in to mark when the the record was added or updated... outside of that date is usually sufficient.
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@sjogan
@sjogan 2 года назад
1. Thank you for a 10 minute video. you have alot of good information, but sometimes as you said, you just want the basics to get up and running. 2. Many times i just wanted the date only or the time only. this will help a lot.
@IAmTimCorey
@IAmTimCorey 2 года назад
I’m glad these will help.
@alisaadat8638
@alisaadat8638 2 года назад
very helpful tankYou
@IAmTimCorey
@IAmTimCorey 2 года назад
You are welcome.
@bardus_hobus
@bardus_hobus 2 года назад
Love 10 minutes…a lot of times I want to watch the longer ones but don’t have the time
@IAmTimCorey
@IAmTimCorey 2 года назад
Great!
@marshallnyamadzawo8553
@marshallnyamadzawo8553 2 года назад
Thanks for a shorter video, convenient enough for a busy schedule. I managed to watch this to the end!
@IAmTimCorey
@IAmTimCorey 2 года назад
Glad you enjoyed it!
@knightmarerip711
@knightmarerip711 2 года назад
Finally! Just not sure why it took them soooo long to do this! By the way, great vid! Love the 10 minute video concept! Very direct to the point!
@tomthelestaff-iamtimcorey7597
@tomthelestaff-iamtimcorey7597 2 года назад
Thanks, please share them around!
Далее
Airpod Through Glass Trick! 😱 #shorts
00:19
Просмотров 1,7 млн
The RIGHT way to deal with Date and Time in C#
8:31
Просмотров 64 тыс.
Intro to Tuples in C# In 10 Minutes or Less
9:50
Просмотров 41 тыс.
Introduction to DateTime in C#: Master the Basics!
23:39
Brutally honest advice for new .NET Web Developers
7:19
Implicit Usings in .NET 6 In 10 Minutes or Less
8:41
Every feature added in C# 10 with examples
15:59
Просмотров 125 тыс.