Solved

how to fill in zeros in a text date

Posted on 2014-07-21
4
219 Views
Last Modified: 2014-07-21
I am trying to automate this entire process without having to look it over.
I have an imported table from excel we'll call XLS_import that I have automated to import by button.
It has several date fields and like always the dates come in many formats from the user.
What I need to do is clean them up in a query.
I need the date to stay a text field.
I would like to say in the query if len<10 then add the right amount of zeros.
so that
              1/1/2014 would end up 01/01/2014
0r          1/12/2014 would end up 01/12/2014.  
Any help would be apprieciated
0
Comment
Question by:Stephen Roesner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40209994
Maybe

strRes = Format(DateValue (strYourDate),  "mm/dd/yyyy")

Regards
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40210175
Take a look for Format() function manual from MS at http://msdn.microsoft.com/en-us/library/office/gg251755(v=office.15).aspx

you can do this,  probably you will put the date string into Excel cell
such as at Cell A1

Duncan

Sub test()
Range("A2") = Format(DateValue(Range("A1")), "dd/mm/yyyy")
Range("A2").NumberFormat = ("dd/mm/yyyy")
End Sub
0
 

Author Comment

by:Stephen Roesner
ID: 40210214
cool at first I typed it in and it didnt work butthen I went thru the formula builder to see if I was missing anything and then it worked. Thanks a lot. I also had to add for is null so the formular ended up
IIf(IsNull([Date],[Date],Format(DateValue([Date]),"mm/dd/yyyy")) and it works perfect!
Thank you so much.
0
 

Author Closing Comment

by:Stephen Roesner
ID: 40210215
Thanks easy and small always the perfect code.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question