Results 1 to 2 of 2

Thread: Formatting different dates

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2012
    Posts
    3

    Formatting different dates

    Trying to format a date that might be less than todays date in VB2010.

    To determine what date I want I use:

    Code:
    dim TheDate as date
    TheDate = Today.AddDays(-1)
    This works and returns a value of yesterdays date in the format of m/dd/yy. I am trying to get the format of "yyyymmdd"

    When ever I try to change the format:

    Code:
    TheDate = format(Today.AddDays(-1), "yyyymmdd")
    I get an error about casting a number, the value must be less than infinity. I think yesterday should be < infinity, but I still get the error.

    Any idea how subtract a day from today and put it in a different format? I see lots of examples of each component on the web, but not both at the same time.

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Formatting different dates

    Well a coupla things,

    Format is a string function so you can't get a date out of it though it does work perfectly as a string ..... 20120818

    mm is minutes, MM is months!

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