Results 1 to 3 of 3
  1. #1
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281

    How to format a julian date to std date in SQL Query

    Greetings...

    I hope this is the correct place to post this...

    When I run the following code (DoCmd.TransferSpreadsheet acImport...) to update a table with values pulled from an excel file in puts the dates in Julian date format

    Thus

    1/2/2018 is uploaded as 43102
    1/3/2018 is uploaded as 43103

    These values are eventually called from another query by date but that query is using date: CDate([FieldName]) with a criteria of: >Date() to extract the dates requested



    However because the dates are in the 43102, 43103, format it recognizes no dates at all and thus pulls no data.

    When I format the field in the table to Date/Time - ShortDate and run the query again it imports the date header but no dates.

    I've tried using CONVERT - No luck,

    I'm not sure if I should try to format the date before or during the import from Excel or after it imports the julian dates and before the next query.

    Below is the SQL Query to take the imported data and move certain dates to another table
    Code:
    SELECT CDate([F1]) AS [date], CInt([F2]) AS RefCRttl, CInt([F5]) AS RefCR2day, CInt([F7]) AS RefCR3day
    FROM tmpRefWTDCR
    WHERE (((CDate([F1]))<Date()) AND ((IsDate([F1]))=-1));
    I hope I have provided enough information to assist...Thank You
    Last edited by RunTime91; 01-10-2018 at 12:43 PM. Reason: Added Code

  2. #2
    Join Date
    Apr 2017
    Posts
    1,680
    Try
    Code:
    SELECT (DATESERIAL(1900,1,0) + [F1]) AS [date], ...

  3. #3
    RunTime91 is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Dec 2014
    Posts
    281
    Brilliant!... Works great, Arvil...Sorry for the late response of gratitude... was away for awhile...

    Thanks again, Arvil

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

Similar Threads

  1. Replies: 6
    Last Post: 07-20-2017, 12:48 PM
  2. Current Date to Julian Date?
    By Hammilton in forum Forms
    Replies: 12
    Last Post: 12-11-2015, 09:27 PM
  3. Replies: 3
    Last Post: 08-20-2014, 01:47 PM
  4. Julian (ordinal) date one day off
    By gregu710 in forum Access
    Replies: 6
    Last Post: 02-02-2012, 06:21 PM
  5. Julian Date Function Help Please
    By campanellisj in forum Programming
    Replies: 3
    Last Post: 05-13-2011, 12:59 PM

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