Advertisement

10.24.2004 at 06:02AM PDT, ID: 21180383
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Convert string to date
Tags: date, convert, string
I'm working with calendar data exported from Outlook.  For some reason, Outlook exports the data as text, not a date/time variable, so I need to convert the data to date/time before I can work with it.

I tried the following:

Private Sub Clean1_Click()
Dim datStartDate2 As Date
Dim strStartDate As String

StartDate.SetFocus
strStartDate = StartDate.Text
datStartDate2 = CDate(strStartDate)
StartDate2.SetFocus
StartDate2.Text = datStartDate

End Sub

but keep coming up with a type mismatch error.

I also tried DateValue instead of CDate but still got a type mismatch error.

I've tried dim-ing datStartDate2 as Date and as Var but still get that error.

Any suggestions?

Kitty
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: prettykittyq
Solution Provided By: cactus_data
Participating Experts: 4
Solution Grade: A
Views: 1338
Translate:
Loading Advertisement...
10.24.2004 at 06:04AM PDT, ID: 12392852

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.24.2004 at 06:15AM PDT, ID: 12392898

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.24.2004 at 06:19AM PDT, ID: 12392923

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.24.2004 at 06:26AM PDT, ID: 12392955

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.24.2004 at 06:32AM PDT, ID: 12392992

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.24.2004 at 08:58AM PDT, ID: 12393874

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.24.2004 at 09:02AM PDT, ID: 12393888

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 03:12AM PDT, ID: 12398680

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 03:17AM PDT, ID: 12398695

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 03:21AM PDT, ID: 12398707

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 03:46AM PDT, ID: 12398819

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 04:40AM PDT, ID: 12399098

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 04:47AM PDT, ID: 12399139

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 04:56AM PDT, ID: 12399203

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 05:04AM PDT, ID: 12399261

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 05:14AM PDT, ID: 12399312

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 05:15AM PDT, ID: 12399316

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
10.25.2004 at 05:20AM PDT, ID: 12399369

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
10.24.2004 at 06:04AM PDT, ID: 12392852

Rank: Genius

Hi prettykittyq,

try
datStartDate2 = Format(strStartDate,"mm-dd-yy")

Hope this helps

Jaffer
 
10.24.2004 at 06:15AM PDT, ID: 12392898

Rank: Genius

For the date conversion there is no reason to set focus.
Also, you need to assign to the Value property:

'StartDate.SetFocus
strStartDate = StartDate.Text
datStartDate2 = CDate(strStartDate)
'StartDate2.SetFocus
StartDate2.Value = datStartDate

/gustav
 
10.24.2004 at 06:19AM PDT, ID: 12392923
Hi

don't know where this is part of your problem or was just a mis type in your post but you are using

StartDate2.Text = datStartDate

but datStartDate doesnt exist so you need

StartDate2.Text = datStartDate2

Cheers

Scott
 
10.24.2004 at 06:26AM PDT, ID: 12392955

Rank: Genius

Scott is right. Still:

StartDate2.Value = datStartDate2

/gustav
 
10.24.2004 at 06:32AM PDT, ID: 12392992

Rank: Genius

if you are reffering to a field on a Form then it should be either

[StartDate2]
OR
me.StartDate2

But I assume these are NOT fields, but variables used to get the data from Outlook.

jaffer
 
10.24.2004 at 08:58AM PDT, ID: 12393874

Rank: Genius

Why not just assign the value directly rather than going through all of the extra variable declarations?

Me!StartDate2=CDate(Me!StartDate)

I have omitted the .Value since that property is implicit (but so is Me!, it's just a matter of style unless you're using .net).
 
10.24.2004 at 09:02AM PDT, ID: 12393888

Rank: Genius

Oh yes - should mention that odding Option Explicit to the top of the module will help troubleshoot these little typos...
 
10.25.2004 at 03:12AM PDT, ID: 12398680
Thanks for the input.

I see I didn't give enough information since none of those suggestions helped so let me try again.

The data has been exported from Outlook Calendar to an Excel file which is linked to an Access table.  In Excel, the dates are showing up as:

'10/25/2004

The apostrophe at the beginning is causing Access (and Excel) to see the data as a string rather than numbers.

In an earlier version of this project, we solved that problem in Excel by using a macro based on Excel's DATEVALUE function which "recognizes" the number part of the string and creates the date equivalent.

I'm now trying to achieve the same end with VBA code in Access, so my user doesn't have to run the Excel macro in Excel.

I have a table called Calendar that is the raw data from Excel.  I am trying to take the string in the StartDate field of the Excel-based table Calendar, run it through the appropriate routine, and store the resulting date in the StartDate2 field of a new table CleanCalendar so that Access will recognize it as a date/time field and not a text field.

I tried using Access's DATEVALUE function but kept getting a type mismatch error.

Then I tried using Access's CDATE function but I keep getting a type mismatch error.

The "set focus" code comes up because I'm retrieving the value of the StartDate field of the current row through the StartDate textbox on my form.

So, the task is really:
1.  Retrieve the string StartDate from table Calendar.
2.  Convert the string StartDate into a date/time value.
3.  Store the date/time value in StartDate2 in table CleanCalendar.

If there's a better way to do this, I'm happy to start over but I'm stymied.

As it happens, each record in Calendar has three of these little devils:  StartDate (a string with date information) and StartTime and EndTime (strings with time information), so I'm going to need to do all of them.

Again, thanks but none of your comments have worked so far.

Kitty
 
10.25.2004 at 03:17AM PDT, ID: 12398695

Rank: Genius

Hmm, you could run this SQL statement:

INSERT INTO CleanCalendar (StartDate, StartTime, EndTime) SELECT CDate(Mid$(StartDate,2)), CDate(Mid$(StartTime,2)), CDate(Mid$(EndTime,2)) FROM Calendar

I think that will do it.
Assisted Solution
 
10.25.2004 at 03:21AM PDT, ID: 12398707

Rank: Genius

Shane, I don't think you need the CDate anywhy, as long as the fields in CleanCalendar are set to Date/Time
 
10.25.2004 at 03:46AM PDT, ID: 12398819

Rank: Genius

First, are you aware that you can link an Excel worksheet or Named Range as a table in Access?
This would save you the import.

Second, the append query could be something like this:

  INSERT INTO tblCalendarA
    (StartDate,
    StartTime,
    EndTime)
  SELECT
    MID(StartDate, 2),
    MID(StartTime, 2),
    MID(EndTime, 2)
  FROM
    Calendar

/gustav
Accepted Solution
 
10.25.2004 at 04:40AM PDT, ID: 12399098
Shane, the SQL statement looks promising but I don't know how to use it.

Would it be part of a query that I'd run to append the new data to the CleanCalendar table?

Or do I need to create a recordset and run a routine with that?

Sorry, I do need a lot of coaching on this.

Thanks for the help.

Kitty
 
10.25.2004 at 04:47AM PDT, ID: 12399139

Rank: Genius

Kitty
Please backup your Data before you do this.

Copy the SQL,
Open a new query,
Menu Bar > View > SQL and paste the SQL
Run the Query using the ! button.

jaffer
Assisted Solution
 
10.25.2004 at 04:56AM PDT, ID: 12399203
Thanks, jaffer.  I tried it and got the error message

"Calendar Project set 240 fields to Null due to a type conversion failure."

The relevant fields in the receiving table (CleanCalnder) were set to date/time.  I went back and changed them to text and that didn't help.

You remarked earlier that I might not need to use CDate.  Should I delete the CDates from the SQL statement?

Kitty
 
10.25.2004 at 05:04AM PDT, ID: 12399261

Rank: Genius

> You remarked earlier that I might not need to use CDate.  Should I delete the CDates from the SQL statement?

Yes, Jaffer is right. Try this:

 INSERT INTO CleanCalendar
    (StartDate,
    StartTime,
    EndTime)
  SELECT
    MID(StartDate, 2),
    MID(StartTime, 2),
    MID(EndTime, 2)
  FROM
    Calendar

/gustav
 
10.25.2004 at 05:14AM PDT, ID: 12399312

Rank: Genius

keep the fields set to date/time, otherwise you will face another issue when using these fields
 
10.25.2004 at 05:15AM PDT, ID: 12399316
Thanks, gustav and jaffer and shane.  It worked just fine once I followed directions.

Kitty
 
10.25.2004 at 05:20AM PDT, ID: 12399369

Rank: Genius

I am glad you got it going,
Thanks for the points and the grade,

Good luck with your project

jaffer
 
 
20080236-EE-VQP-29