Results 1 to 10 of 10
  1. #1
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36

    Year wise Date spliting

    Sir I have table with two field: [STARTDATE] and [ENDDATE], Suppose the start date may be 15/05/2005 and the enddate may be 25/8/2009. Now I want to split these days like following;
    15/05/2005 to 31/12/2005
    1/1/2006 to 31/12/2006
    1/1/2007 to 31/12/2007
    1/1/2008 to 31/12/2008


    1/1/2009 to 25/08/2009
    The above details may be get in a table or a query with two fields. How can i do this with access. I am not efficient in VBA. Please help me

  2. #2
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Sir I have table with two field: [STARTDATE] and [ENDDATE], Suppose the start date may be 15/05/2005 and the enddate may be 25/8/2009. Now I want to split these days like following;
    15/05/2005 to 14/05/2006
    15/05/2006 to 14/05/2007
    15/05/2007 to 14/05/2008
    15/05/2008 to 14/05/2009
    15/05/2009 to 25/08/2009
    These type of splitting is also needed

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    you will need another field to indicate which type of split you require

    you will also need another table, perhaps based on years and used in a cartesian query with your current table

    until your requirement is perfectly clear, difficult to be more specific.

  4. #4
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Ajax sir.... I am always thankful to u. Your query (AJAXQ, I named that in my software) for my previous post (ACRSTDT,ACRENDT) is working well...and is used in my office, That software is a success one..all officials appreciating me for developing such a handy software...But i know all its working is only with your magical query which you sent me..thank u sir..
    Now I am trying to develop another software for calculating earned leave of a Govt.Employees (Earned leave means; Employee earned One EL, while in duty for 11 days, i.e an employee will earn 33-2/11 EL in a year 33-3/11 in a leap year), While retiring an employee we have to calculate the balance EL for surrendering the same for money. I have almost succeeded. But the result is only summery. We also want the detailed report of the leave details, ie for each year, that is why I post such a thread ..Now I need only the answer of the following question.
    Sir I have table with two field: [STARTDATE] and [ENDDATE], Suppose the start date may be 15/05/2005 and the enddate may be 25/8/2009. Now I want to split these days like following;
    15/05/2005 to 14/05/2006
    15/05/2006 to 14/05/2007
    15/05/2007 to 14/05/2008
    15/05/2008 to 14/05/2009
    15/05/2009 to 25/08/2009
    I am attaching some scree shot of my half cooked project! Thanking you sir

  5. #5
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Screen shot
    Attached Thumbnails Attached Thumbnails 1.jpg   2.jpg   3.jpg   4.jpg   5.jpg  


  6. #6
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Screen shot continuing
    Attached Thumbnails Attached Thumbnails 6.jpg   7.jpg   8.jpg  

  7. #7
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Sir I want to get result like this
    Attached Thumbnails Attached Thumbnails 9.jpg  

  8. #8
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Quote Originally Posted by Ajax View Post
    you will need another field to indicate which type of split you require

    you will also need another table, perhaps based on years and used in a cartesian query with your current table

    until your requirement is perfectly clear, difficult to be more specific.
    Sir Please help me

  9. #9
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    I do not need to see screen shots, I need to see table and field names, and relationships

    So best guess per the requirement in post#4

    1. create a table called CTR. It contains a single number field (long type) called Counter and should be populated with 0,1,2,3 etc up to a maximum number of your deciding - based on your example suggest 10 might be enough

    2. next create this query - change names to suit

    SELECT DateAdd("yyyy",[counter],[startDate]) AS Date1, IIf(DateAdd("yyyy",[counter]+1,[startDate])<[endDate],[endDate],DateAdd("yyyy",[counter]+1,[startDate])-1) AS Date2
    FROM CTR, myTable
    WHERE (((Counter)<=DateDiff("yyyy",[startDate],[endDate])))
    ORDER BY Counter


    I do not have much free time right now so if this is not what you require, or there are other factors you have not mentioned, you will need to work it out for yourself

    good luck with your project

  10. #10
    rohinikrishna1987 is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jul 2020
    Posts
    36
    Quote Originally Posted by Ajax View Post
    I do not need to see screen shots, I need to see table and field names, and relationships

    So best guess per the requirement in post#4

    1. create a table called CTR. It contains a single number field (long type) called Counter and should be populated with 0,1,2,3 etc up to a maximum number of your deciding - based on your example suggest 10 might be enough

    2. next create this query - change names to suit

    SELECT DateAdd("yyyy",[counter],[startDate]) AS Date1, IIf(DateAdd("yyyy",[counter]+1,[startDate])<[endDate],[endDate],DateAdd("yyyy",[counter]+1,[startDate])-1) AS Date2
    FROM CTR, myTable
    WHERE (((Counter)<=DateDiff("yyyy",[startDate],[endDate])))
    ORDER BY Counter


    I do not have much free time right now so if this is not what you require, or there are other factors you have not mentioned, you will need to work it out for yourself

    good luck with your project
    I wont disturb you in future sir.......

    Thank u for every things sir, Your query is working super sir ....first time it was show some error, then i checked it and I have replace < to > then it working superb thank u sir

    ELECT DateAdd("yyyy",[counter],[startDate]) AS Date1, IIf(DateAdd("yyyy",[counter]+1,[startDate])>([endDate],[endDate],DateAdd("yyyy",[counter]+1,[startDate])-1) AS Date2
    FROM CTR, myTable
    WHERE (((Counter)<=DateDiff("yyyy",[startDate],[endDate])))
    ORDER BY Counter

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

Similar Threads

  1. Replies: 1
    Last Post: 11-03-2016, 03:14 AM
  2. Replies: 7
    Last Post: 06-07-2015, 11:57 PM
  3. Replies: 4
    Last Post: 01-09-2013, 11:16 AM
  4. Replies: 0
    Last Post: 07-16-2012, 01:48 PM
  5. minus date wise sales a=n?
    By alex_raju in forum Access
    Replies: 1
    Last Post: 07-30-2011, 01:23 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