Results 1 to 5 of 5
  1. #1
    jrdnoland is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Ohio
    Posts
    41

    Having Date format issues with query being run.

    I'm trying to run a query that will drop off experiments if the experiment closed date is before the current date.



    Using Excel 2019 and Oracle 12g.

    Code:
    SELECT distinct e.EXPERIMENT_NUMBER, e.name,
    (SELECT value FROM WORKBOOK_DATA WHERE NAME = 'Instrument' AND WORKBOOK_NUMBER = wb.WORKBOOK_NUMBER), 
    (SELECT value FROM WORKBOOK_DATA WHERE NAME = 'Exp_Date' AND WORKBOOK_NUMBER = wb.WORKBOOK_NUMBER) 
    FROM EXPERIMENT e JOIN WORKBOOK wb ON wb.EXPERIMENT_NUMBER = e.EXPERIMENT_NUMBER 
    JOIN WORKBOOK_DATA wd ON wd.WORKBOOK_NUMBER = wb.WORKBOOK_NUMBER WHERE wd.NAME IN ('Instrument', 'Exp_Date') 
    AND ((wd.NAME = 'Exp_Date') AND To_Date(wd.VALUE,'DD/MON/YY') > To_Date(CURRENT_DATE, 'DD/MON/YY') 
    OR (wd.NAME = 'Instrument')) AND e.NAME LIKE '%_CAL%' 
    AND e.GROUP_NAME IN ('ANALYTICAL_PL_RD','DEVELOPMENT_PL_RD','MICRO_PL_RD','RD_PROCESSRESEARCH','PD_PL_RD','SCS_PL_RD')
    I get the error
    Code:
    ORA-01861: literal does not match format string
    01861. 00000 -  "literal does not match format string"
    *Cause:    Literals in the input must be the same length as literals in
               the format string (with the exception of leading whitespace).  If the
               "FX" modifier has been toggled on, the literal must match exactly,
               with no extra whitespace.
    *Action:   Correct the format string to match the literal.
    How do I get the literals to match? The date format of the Oracle field is DD-MON-RR

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    MON is not a format in microsoft.
    month format is MM

  3. #3
    jrdnoland is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Ohio
    Posts
    41
    Quote Originally Posted by ranman256 View Post
    MON is not a format in microsoft.
    month format is MM
    Yes, but the oracle database holding the data is DD-MON-RR, Ive tried formatting to DD-MM-YYYY with the same error message. Using To_Date and have also tried SYSDATE to get current date.

    Thanks for taking the time to look at my post and respond!

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Just did some googling and found this link

    Sample from the site:
    "You convert string to date with a different format. Try this

    select to_char(to_date(’25-SEP-14′,’DD-MON-YY’), ‘DD/MM/YYYY’) FROM DUAL"

  5. #5
    jrdnoland is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Apr 2010
    Location
    Ohio
    Posts
    41
    Quote Originally Posted by orange View Post
    Just did some googling and found this link

    Sample from the site:
    "You convert string to date with a different format. Try this

    select to_char(to_date(’25-SEP-14′,’DD-MON-YY’), ‘DD/MM/YYYY’) FROM DUAL"
    Thank you Orange! Appreciate the help.

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

Similar Threads

  1. Replies: 6
    Last Post: 04-06-2020, 04:31 AM
  2. Access into Excel - Format Issues
    By CharlotteAllen in forum Import/Export Data
    Replies: 6
    Last Post: 02-25-2019, 06:30 PM
  3. Replies: 2
    Last Post: 01-14-2018, 08:59 PM
  4. Format Date query
    By fluffyvampirekitten in forum Queries
    Replies: 4
    Last Post: 10-28-2015, 12:48 AM
  5. Date format issues
    By budedwards in forum Queries
    Replies: 14
    Last Post: 03-15-2012, 10:52 AM

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