Results 1 to 11 of 11

Thread: [RESOLVED] Date format

Hybrid View

  1. #1

    Thread Starter
    Lively Member viper5646's Avatar
    Join Date
    Feb 2009
    Location
    kitchener Ontario
    Posts
    90

    Re: Date format

    Thanks Jmcilhinney
    Here how I'm using my date. I use this code to acquire the date and format it.
    [CODE] Public m_Today As String = FormatDateTime(Now, DateFormat.GeneralDate)/CODE]
    And then I convert it to date as follows.
    Code:
      Dim todaydate As Date = CDate(RogersForm.m_Today)

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Date format

    Quote Originally Posted by viper5646 View Post
    [CODE] Public m_Today As String = FormatDateTime(Now, DateFormat.GeneralDate)/CODE]

    Code:
      Dim todaydate As Date = CDate(RogersForm.m_Today)
    Perhaps you could refrain from putting your actual comments inside QUOTE tags. QUOTES are for quoting other posts, not your own.

    As for the issue, there is absolutely no point, under any circumstances, in converting a Date to a String and back to a Date. Like I said, Dates are binary objects that have no format so you can't possible gain anything by that and you might end up losing data or causing an error. If you want today's date then use today's date:
    Code:
    Dim todaysDate As Date = Date.Today
    You then need to insert that value into the database as a binary date, NOT as text. You haven't actually provided us with the code that you use to insert the data into the database as I requested.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width