Results 1 to 2 of 2

Thread: Storing a date into three variables

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    184

    Question

    I would like to have the date 2/3/00 stored
    as three variables....

    2 = dayvar
    3 = monthvar
    00 = yearvar

    how can I take that date (it will change
    everytime.... )

    Evan
    Evan Duffield --------
    --- [email protected]
    - -
    VB6 - Learning Edition
    - -


  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Posts
    461
    How is the date given to you?

    As a Date? ( DateValue("2/3/00") )
    Or as a String? ( "2/3/00" )

    If its as a date you can do the following :

    Code:
    Dim dtDate as Date
    Dim dayvar as integer, monthvar as integer, yearvar as integer
    
    dtDate = DateValue("2/3/00")
    
    dayvar = day(dtDate)
    monthvar = month(dtDate)
    yearvar = year(dtDate)
    If it is given to you as a string you can do :

    Code:
    Dim cDate as String
    Dim dtDate as Date
    Dim dayvar as integer, monthvar as integer, yearvar as integer
    
    dtDate = DateValue(cDate)
    
    dayvar = day(dtDate)
    monthvar = month(dtDate)
    yearvar = year(dtDate)
    Just in case you are not sure about it being a string or a date... Getting the value from a TextBox means it is a string... getting it from a field in a database where it is stored as a date means you get it as a date.

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