Results 1 to 6 of 6
  1. #1
    cliff.clayman is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    55

    Exclamation Date formatting in an Access 2010 query

    I have a Date field that I need to format and do a null check on. Here is what I tried so far and it doe not seem to be working. I am trying to compare two dates fields to see if they match.



    Here is the code for the first field:

    ADCC1: CDate(Format(IIf(IsNull([ADCC]),#1/1/1900#,[ADCC]),"mm/dd/yyyy"))

    Here is the code for the second field. I do not need to format this field as it is already formatted properly:

    LCD1: IIf(IsNull([LCD]),#1/1/1900#,[LCD])

    Here is the Criteria I am trying to do on [LCD] to compare it to [ADCC]:

    CDate(Format(IIf(IsNull([ADCC]),#1/1/1900#,[ADCC]),"mm/dd/yyyy"))

    Please help as it is not returning the proper results!

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    Cdate converts a string to a date so you need to be clear are you comparing two string datatypes or two date datatypes?

    you can also simply your code by using the nz function

    if your fields are both date types then

    nz(ADCC1,#01/01/1900#)=nz(LCD1,#01/01/1900#)

  3. #3
    cliff.clayman is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    55
    Both fields are date/time, but ADCC has a timestamp whereas LCD does not.

  4. #4
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    in that case

    datevalue(nz(ADCC1,#01/01/1900#))=nz(LCD1,#01/01/1900#)

  5. #5
    cliff.clayman is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2015
    Posts
    55
    Here is what I did and it worked:

    ADCC1: Format(Nz([ADCC],#1/1/1900#),"mm/dd/yyyy")

    Criteria for LCD field:

    <>Format(Nz([ADCC],#1/1/1900#),"mm/dd/yyyy")

  6. #6
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,927
    converting to a string is probably slower but wont be apparent is small datasets

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

Similar Threads

  1. Normalizing formatting in Access 2010
    By Briilee in forum Access
    Replies: 4
    Last Post: 06-09-2015, 08:15 AM
  2. Replies: 3
    Last Post: 12-02-2014, 07:58 PM
  3. Replies: 18
    Last Post: 09-24-2014, 02:44 PM
  4. Conditional Formatting on an Access 2010 Report
    By ecalvert47462 in forum Reports
    Replies: 1
    Last Post: 02-18-2014, 12:18 PM
  5. Graph Formatting in Access 2010 Report
    By RayMilhon in forum Reports
    Replies: 13
    Last Post: 03-16-2012, 05:23 PM

Tags for this Thread

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