+ Reply to Thread
Results 1 to 4 of 4

Trouble Converting Text Date To Date

  1. #1
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Trouble Converting Text Date To Date

    I am trying to convert a text date from a userform textbox into a date value for the purposes of comparison.

    Please Login or Register  to view this content.
    The textbox date is formatted as "dddd, mmmm dd, yyyy" (Monday, March 18, 2019). datetofind is defined as 'date'
    I though Cdate would do it, but it simply results in a "Type mismatch" error.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Trouble Converting Text Date To Date

    From: https://www.excelfunctions.net/vba-cdate-function.html

    CDate Expression Types

    The VBA Date data type holds both date and time information. Therefore the Expression that is supplied to the CDate function must be able to be interpreted as a valid VBA date or time.

    The CDate function can interpret text representations of dates and times that are in a recognised Excel format. However, the function is unable to interpret dates that include the text description of the weekday (Sunday, Monday, etc).
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Forum Contributor
    Join Date
    06-15-2009
    Location
    Ontario, canada
    MS-Off Ver
    Office 365
    Posts
    371

    Re: Trouble Converting Text Date To Date

    So, this worked ... but I might be doing something in a more complicated manner than necessary.

    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Trouble Converting Text Date To Date

    Sure, whatever works. I would have used InStr, Len, and Right. I didn't type this into VBA, but you should be able to get the idea.

    dayval = CDate(Right(uf9_poststaff.processdate.Value, Len(uf9_poststaff.processdate.Value)-InStr(1,uf9_poststaff.processdate.Value," ")))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Weird error: converting text date to date format
    By rjcarlantonio in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 09-18-2018, 02:04 PM
  2. Need help converting text to date for merging date entries
    By oladunk in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-04-2017, 03:22 AM
  3. [SOLVED] Converting Date Text to Number format to use in a VLOOKUP to polpulate data based by date
    By Rossovich in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-08-2015, 10:43 AM
  4. Converting Text to Date & Sorting on Date
    By andresndor in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-10-2014, 04:48 PM
  5. Converting text string that contains a date and time to a date
    By jmforde in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-12-2013, 02:31 PM
  6. Converting date text to date format
    By reggie1000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-01-2009, 06:10 AM
  7. Input box - trouble with converting to date
    By howard101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2007, 12:56 PM

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