Results 1 to 2 of 2

Thread: [RESOLVED] [2005] Date Variables

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2006
    Posts
    18

    Resolved [RESOLVED] [2005] Date Variables

    To set a date to a date variable, you use:

    date variable = #some date#

    Can you do this with variables as the days, months and years? something like this?:

    date variable = #month variable/day variable/year variable#

    It doesn't let me do that. It underlines the first hash sign and says: 'expression expected'. what does it mean and how (if its possible) do you set a date with variables as the days, months and years?

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

    Re: [2005] Date Variables

    No you can't. The '#' symbols are used for date literals only. If you want to build a Date using variables you have to use a Date constructor, e.g.
    VB Code:
    1. Dim myDate As Date = New Date(years, months, days)
    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