Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2009
    Posts
    1

    Unhappy I need help writing a query statement

    Hi everyone,



    I am in need of help converting a date (ex: 01/01/2009 = 200901) to a string format as YYYYMM. I need to do this in a query. I am not advanced enough to solve visual basic coding.
    This code below was written by someone who is no longer with the company. Can someone help me write this in a query to convert a date format to a string format as listed below.

    Query statement:
    YYYYMM: getYYYYMM([date shut down])

    Calling this function:
    Function getYYYYMM(ByVal dt As Date) As Long
    Dim nYear As Long
    nYear = Year(dt)
    Dim nMONTH As Long
    nMONTH = Month(dt)
    getYYYYMM = 100 * nYear + nMONTH
    End Function

  2. #2
    jya is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2007
    Location
    Chicagoland
    Posts
    109
    There are other ways and probably better ones, but here is what came to mind...

    Expr1: Year([Date Shut Down]) & IIf(Month([Date Shut Down])<10,"0" & Month([Date Shut Down]),Month([Date Shut Down]))

Please reply to this thread with any new information or opinions.

Similar Threads

  1. If then statement in query
    By ronnie4 in forum Queries
    Replies: 1
    Last Post: 01-20-2009, 10:49 AM
  2. Replies: 0
    Last Post: 05-17-2008, 01:18 AM
  3. IF Statement with Minutes
    By sal_gxer in forum Queries
    Replies: 0
    Last Post: 02-12-2007, 08:39 AM
  4. multiple iif statement NEED HELP PLZ
    By scott munkirs in forum Reports
    Replies: 1
    Last Post: 09-27-2006, 05:21 AM
  5. Force writing from the right in a field?
    By Looping in forum Forms
    Replies: 0
    Last Post: 01-23-2006, 03:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums