Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to fill in zeros in a text date

Posted on 2014-07-21
4
Medium Priority
?
221 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 2000 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

722 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