Results 1 to 8 of 8
  1. #1
    lsingh165 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Location
    Sydney, Australia
    Posts
    9

    How to calculate no of days between date job is open and today's date

    Hello,

    What's the formula we can use to calculate days between no of days between date job is open and today's date in a query. I am using formulat below formula but the DATE_OPEN and Today (todays date) pops us as enter parameter value. I dont want those enter parameter windows pops us. The date job is open is in a linked table and linked table is getting the information from BPCS software. The date in Liinked is in format YYYYMMDD. Please help

    Total Days: DateDiff("d",[Date_Open],[Today])



    The SQL Details are below. AUNPRDF_AAA802 is a linked table and information gets updated on 12 am everyday

    SELECT DateDiff("d",[Date_Open],[Today]) AS [Total Days], AUNPRDF_AAA802.AAAGE AS Age, AUNPRDF_AAA802.AAORD AS [Job Number], AUNPRDF_AAA802.AAWKSP AS Workshop, AUNPRDF_AAA802.AASWKT AS WorkType, AUNPRDF_AAA802.AANAME AS [Customer Name], AUNPRDF_AAA802.AANME AS [Service Admin], AUNPRDF_AAA802.AASDE1 AS Complaint, AUNPRDF_AAA802.AASDE2 AS Cause, AUNPRDF_AAA802.AASDE3 AS Correction, Sum(AUNPRDF_AAA802.AATOT) AS Total, CDate(Right([AAODTE],2) & "/" & Mid([AAODTE],5,2) & "/" & Left([AAODTE],4)) AS Date_Open, Date() AS Today
    FROM AUNPRDF_AAA802
    GROUP BY DateDiff("d",[Date_Open],[Today]), AUNPRDF_AAA802.AAAGE, AUNPRDF_AAA802.AAORD, AUNPRDF_AAA802.AAWKSP, AUNPRDF_AAA802.AASWKT, AUNPRDF_AAA802.AANAME, AUNPRDF_AAA802.AANME, AUNPRDF_AAA802.AASDE1, AUNPRDF_AAA802.AASDE2, AUNPRDF_AAA802.AASDE3, CDate(Right([AAODTE],2) & "/" & Mid([AAODTE],5,2) & "/" & Left([AAODTE],4)), Date(), AUNPRDF_AAA802.AARTYP
    HAVING (((AUNPRDF_AAA802.AARTYP)="1"));

    Thanks

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    I'm not sure this is right but you could try:
    DateDiff("d",Format([Date_Open],"mm/dd/yyyy"),Format(Date(),"mm/dd/yyyy"))
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    lsingh165 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Location
    Sydney, Australia
    Posts
    9
    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	116.3 KB 
ID:	10904
    Still enter value parameter for Date_Open and Today's Date comes up when I run the query, Please help mate. Thanks for reply

  4. #4
    lsingh165 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Location
    Sydney, Australia
    Posts
    9
    The linked table is pulling all the data out BPCS software and date is in a format YYYYMMDD without any back slash or dash in it. I applied formula in query to have date in format dd/mm/yyyy so that i can calculate the total days between Date_Open and today. I dont know why query is asking me for these parameters. Could you please help mate

  5. #5
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Can you show us the SQL of the query as it is now.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  6. #6
    lsingh165 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Location
    Sydney, Australia
    Posts
    9
    SELECT DateDiff("d",[Date_Open],[Today]) AS [Total Days], AUNPRDF_AAA802.AAAGE AS Age, AUNPRDF_AAA802.AAWKSP AS Workshop, AUNPRDF_AAA802.AAORD AS [Job Number], AUNPRDF_AAA802.AASWKT AS WorkType, AUNPRDF_AAA802.AANAME AS [Customer Name], AUNPRDF_AAA802.AANME AS [Service Admin], AUNPRDF_AAA802.AASDE1 AS Complaint, AUNPRDF_AAA802.AASDE2 AS Cause, AUNPRDF_AAA802.AASDE3 AS Correction, Sum(AUNPRDF_AAA802.AATOT) AS Total, CDate(Right([AAODTE],2) & "/" & Mid([AAODTE],5,2) & "/" & Left([AAODTE],4)) AS Date_Open, Date() AS Today
    FROM AUNPRDF_AAA802
    GROUP BY DateDiff("d",[Date_Open],[Today]), AUNPRDF_AAA802.AAAGE, AUNPRDF_AAA802.AAWKSP, AUNPRDF_AAA802.AAORD, AUNPRDF_AAA802.AASWKT, AUNPRDF_AAA802.AANAME, AUNPRDF_AAA802.AANME, AUNPRDF_AAA802.AASDE1, AUNPRDF_AAA802.AASDE2, AUNPRDF_AAA802.AASDE3, CDate(Right([AAODTE],2) & "/" & Mid([AAODTE],5,2) & "/" & Left([AAODTE],4)), Date(), AUNPRDF_AAA802.AARTYP
    HAVING (((AUNPRDF_AAA802.AAWKSP)="AP") AND ((AUNPRDF_AAA802.AARTYP)="1")) OR (((AUNPRDF_AAA802.AAWKSP)="KR") AND ((AUNPRDF_AAA802.AARTYP)="1") AND (("WP")<>False)) OR (((AUNPRDF_AAA802.AAWKSP)="WP") AND ((AUNPRDF_AAA802.AARTYP)="1") AND (("KR")<>False));

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Try:
    SELECT DateDiff("d",[Date_Open],Date()) AS [Total Days], AUNPRDF_AAA802.AAAGE AS Age, AUNPRDF_AAA802.AAWKSP AS Workshop, AUNPRDF_AAA802.AAORD AS [Job Number], AUNPRDF_AAA802.AASWKT AS WorkType, AUNPRDF_AAA802.AANAME AS [Customer Name], AUNPRDF_AAA802.AANME AS [Service Admin], AUNPRDF_AAA802.AASDE1 AS Complaint, AUNPRDF_AAA802.AASDE2 AS Cause, AUNPRDF_AAA802.AASDE3 AS Correction, Sum(AUNPRDF_AAA802.AATOT) AS Total, CDate(Right([AAODTE],2) & "/" & Mid([AAODTE],5,2) & "/" & Left([AAODTE],4)) AS Date_Open
    FROM AUNPRDF_AAA802
    GROUP BY DateDiff("d",[Date_Open],Date()), AUNPRDF_AAA802.AAAGE, AUNPRDF_AAA802.AAWKSP, AUNPRDF_AAA802.AAORD, AUNPRDF_AAA802.AASWKT, AUNPRDF_AAA802.AANAME, AUNPRDF_AAA802.AANME, AUNPRDF_AAA802.AASDE1, AUNPRDF_AAA802.AASDE2, AUNPRDF_AAA802.AASDE3, CDate(Right([AAODTE],2) & "/" & Mid([AAODTE],5,2) & "/" & Left([AAODTE],4)), Date(), AUNPRDF_AAA802.AARTYP
    HAVING (((AUNPRDF_AAA802.AAWKSP)="AP") AND ((AUNPRDF_AAA802.AARTYP)="1")) OR (((AUNPRDF_AAA802.AAWKSP)="KR") AND ((AUNPRDF_AAA802.AARTYP)="1") AND (("WP")<>False)) OR (((AUNPRDF_AAA802.AAWKSP)="WP") AND ((AUNPRDF_AAA802.AARTYP)="1") AND (("KR")<>False));
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    lsingh165 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Location
    Sydney, Australia
    Posts
    9
    Thanks Bob.......I used your query and Now enter parameter value Today (Today's date) doesn't comes up. but still query ask me to Date_Open as enter parameter valueClick image for larger version. 

Name:	date_open.PNG 
Views:	7 
Size:	18.0 KB 
ID:	10920 This is the screen shot. Is thr any way we can get rid of it. I don't want this window to pop up when i run query

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

Similar Threads

  1. Replies: 5
    Last Post: 10-12-2012, 11:00 AM
  2. Get the weekending date from today's date
    By Huddle in forum Access
    Replies: 10
    Last Post: 06-20-2012, 04:05 PM
  3. Replies: 12
    Last Post: 04-26-2012, 04:01 AM
  4. Replies: 1
    Last Post: 11-12-2010, 01:16 AM
  5. Replies: 2
    Last Post: 07-31-2009, 06:56 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