Content Obsolete

This content is no longer current. Our recommendation for up to date content: http://channel9.msdn.com/Series/Visual-Basic-Fundamentals-for-Absolute-Beginners

Sign in to queue

Description

Dates and times are represented using special types (just like strings are) and deserve some attention. In this lesson we learn how to work with Date and Time data, how to create new instances of Date, how to add time; format the data for display and more. Furthermore, we discuss the TimeSpan class as a means of representing a duration of time.

Download the source code for Working with Dates

Embed

Download

The Discussion

  • User profile image
    Kieth

    A point to note in this lesson; when converting a literal date, it must be in US format or it will either reject it or incorrectly convert it.
    e.g My birthdate is July 20th and I live in Australia. The way it is written in Australia is #20/07/1951# but this will be rejected by the compiler. If however you enter as #07/20/1951# it correctly displays on the screen using local format (20/07/1951).
    I notice that this is also the case when writing dates in an SQL string.

  • User profile image
    BobTabor

    @Kieth: Thank you very much for making that point.  Clearly, I'm speaking purely from a USA perspective, and I apologize.  Bad habit when speaking to a global audience!  Again, sincere thanks for adding that note!

  • User profile image
    mark52c

    Bob-I've been working my way through these videos, and I just wanted to take a minute and thank you for putting this series together.  I wouldn't call myself an "absolute beginner" but instead would say that "I know enough about visual basic to be dangerous".  Thanks for the great review!  Also, I wouldn't worry too much about being around 16,000 days old - the number I calculated based on my birth date was about 22,000.  And I don't feel a day over 16,000!

Add Your 2 Cents