+ Reply to Thread
Results 1 to 3 of 3

Convert Date to number

Hybrid View

  1. #1
    BigPig
    Guest

    Convert Date to number

    Hi all,

    Question: How do I convert the Date selected from a calendar to a numerical
    date?

    Example: I have a user form with a command button that pulls up a calendar,
    and of course the user can select a date and so on. The issue is that the
    form requires a date in a numerical format, ie yymmdd, with no hash marks
    (all together). I know how to put it in the spreadsheet and convert the
    values by separating them and then concatenating them, but I am stumped on
    how to code it to do the same without resorting to putting on a spreadsheet,
    converting, concatenating and so on.

    My thought is that there has to be a way to do that via code, in lieu of
    putting the date on a spreadsheet and letting the spreadsheet do the work.

    My thanks to any and all whether or not I can solve my dilemna.

  2. #2
    Chip Pearson
    Guest

    Re: Convert Date to number

    Just use the Format function on the calendar's Value property.

    MsgBox Format(Me.Calendar1.Value, "yymmdd")


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com

    "BigPig" <[email protected]> wrote in message
    news:[email protected]...
    > Hi all,
    >
    > Question: How do I convert the Date selected from a calendar to
    > a numerical
    > date?
    >
    > Example: I have a user form with a command button that pulls up
    > a calendar,
    > and of course the user can select a date and so on. The issue
    > is that the
    > form requires a date in a numerical format, ie yymmdd, with no
    > hash marks
    > (all together). I know how to put it in the spreadsheet and
    > convert the
    > values by separating them and then concatenating them, but I am
    > stumped on
    > how to code it to do the same without resorting to putting on a
    > spreadsheet,
    > converting, concatenating and so on.
    >
    > My thought is that there has to be a way to do that via code,
    > in lieu of
    > putting the date on a spreadsheet and letting the spreadsheet
    > do the work.
    >
    > My thanks to any and all whether or not I can solve my dilemna.




  3. #3
    BigPig
    Guest

    Re: Convert Date to number

    Chip,

    Thanks for the advice! Just what I needed.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1