1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access module to convert date

Discussion in 'Business Applications' started by officework13, Jan 6, 2011.

Thread Status:
Not open for further replies.
  1. officework13

    officework13 Thread Starter

    Joined:
    Mar 2, 2004
    Messages:
    85
    Problem: Access table was provided to me with the date fields as integer format (20040625). There are 20 tables with various different date fields in each one.
    I need to run various queries that will convert the date into date format (06/25/2004).
    I have developed the following formula to do this (the field name was [HireDate]

    DateSerial((Mid([HireDate],1,4)),(Mid([HireDate],5,2)),(Mid([HireDate],7,2)))

    This returns the correct result and so I know that the query works.

    What I need.
    I need a module that will enable me to access the formula from within the expression builder and apply the same formula to the various different date fields within the different tables that I may require

    Example
    table name – T1
    Date field name – D1

    Your assistance is much appreciated
     
  2. OBP

    OBP

    Joined:
    Mar 8, 2005
    Messages:
    19,895
    Take a look at this database, the query you need is convertdate, the module is module1 and the Function is Function mydate(Data As String)
     

    Attached Files:

  3. officework13

    officework13 Thread Starter

    Joined:
    Mar 2, 2004
    Messages:
    85
    late last night after looking at some other websites and reading some books i came across some other information helping me to develop the solution so i thought i would post it.

    Public Function ConvertDate(varDate As Variant) As Date

    Dim strDate As String

    strDate = Nz(varDate, "0")

    ConvertDate = 0

    If strDate <> "0" Then ConvertDate = CDate(Mid(strDate, 1, 4) & "/" & Mid(strDate, 5, 2) & "/" & Mid(strDate, 7, 2))
    End Function

    The formula noted here works near identical to the one i had above, but this one seems work just a bit faster.

    thanks for the reply.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/973030

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice