Results 1 to 4 of 4

Thread: US to UK Date?

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    5

    US to UK Date?

    Hi,

    Trying to convert a Date from mm/dd/yyyy to dd/mm/yyyy using

    Code:
        Public Function USToUKDate(ByRef USDate As String) As Date
            Dim Newdate() As String = USDate.Split("/")
            'Converts from US date format "01/20/2001" to UK 01/02/2013'
            Dim UKDate As String = Newdate(1) & "/" & Newdate(0) & "/" & Newdate(2)
            USToUKDate = CDate(UKDate)
    Howver VB is throwing the following error

    Conversion from string "01/27/2010" to type 'Date' is not valid
    Any ideas why?
    Thanks

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2013
    Posts
    5

    Re: US to UK Date?

    Quote Originally Posted by .paul. View Post
    Thanks

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: US to UK Date?

    Something else I'd like to add... a date is a date... it has no format... so you shouldn't really care whether it is in US or UK or Marian format... because that's all it is ... a format... now, when you display the date, sure... then yes you care about the format... but only at display time.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

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