We help IT Professionals succeed at work.

MS Access Convert 'CCYY-MM-DD' To DateTime Type

Bob Collison
Bob Collison asked
on
393 Views
Last Modified: 2014-05-20
I have a DateTime field in a MS Access Application / Table that I need to load with the String  "CCYY-MM-DD" in an Event Procedure when the extracted data for loading doesn't have a value.

PRC_END_DATE is Data Type DateTime in both tables.

Here is the code that produces a Type Mismatch error.

If Not IsNull(RS_10_MEMBER_MSTR_120!PRC_END_DATE) And RS_10_MEMBER_MSTR_120!PRC_END_DATE <> "" Then
   RS_10_MEMBER_MSTR_110!PRC_END_DATE = RS_10_MEMBER_MSTR_120!PRC_END_DATE
Else
   RS_10_MEMBER_MSTR_110!PRC_END_DATE = "1900-01-01"
End If

How should this be done?
Thanks.
Bob C.
Comment
Watch Question

GozrehSoftware Developer
CERTIFIED EXPERT

Commented:
RS_10_MEMBER_MSTR_110!PRC_END_DATE = CDate("1900-01-01")



Do you have this field on a form ?
Or do you want to edit them straight into the tables? if yes you will need to set a recordset
Bob CollisonSystem Architect

Author

Commented:
The filed is not on a form.

I'm editing straight into the table.  I have all of the code for the Record Sets in place and everything works for all data types (Integer / Text) other than Date/Time.
GozrehSoftware Developer
CERTIFIED EXPERT

Commented:
Did you try  CDate("1900-01-01")
Or  #1900-01-01#

on which line of code are you getting the mismatch error ?
Bob CollisonSystem Architect

Author

Commented:
Hi Gozreh,
This is the line where the error occurs.
 RS_10_MEMBER_MSTR_110!PRC_END_DATE = "1900-01-01"

Sorry  I previously missed your line of code below.
RS_10_MEMBER_MSTR_110!PRC_END_DATE = CDate("1900-01-01")

I will try it but probably not until tomorrow.

Thanks.
Bob C.
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Bob CollisonSystem Architect

Author

Commented:
Hi Gustav,
Both of these solutions work great!
Thanks.
Bob C.
CERTIFIED EXPERT
Most Valuable Expert 2015
Distinguished Expert 2018

Commented:
You are welcome!

/gustav

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.