What to do in Philly for a day?

In MS Access, what query expression do I need to group julian day by 10 day bins? Ex: Julian day 1 - 10 will be group 1

  • I've written this code, but access says it's too complex. Any suggestions to get it simpler? Binned: IIf([Julian Day]<11,"Bin 1",(IIf([Julian Day]<21,"Bin 2",(IIf([Julian Day]<31,"Bin 3",(IIf([Julian Day]<41,"Bin 3",(IIf([Julian Day]<51,"Bin 4",(IIf([Julian Day]<61,"Bin 5",(IIf([Julian Day]<71,"Bin 6",(IIf([Julian Day]<81,"Bin 7",(IIf([Julian Day]<91,"Bin 8",(IIf([Julian Day]<101,"Bin 9",(IIf([Julian Day]<111,"Bin 10",Null))))))))))))))))))))) I need to goto Julian day 140.

  • Answer:

    Is [Julian Day] a field name of a date field? If so, then try this query: SELECT [Julian Date], int((datepart('y', [Julian Date]) - 1) /10) + 1 as Bin FROM [TheTable] The datepart function with the 'y' flag converts the date to the Julian day of the year. Subracting 1 from that day offsets the number so that 10 is included with 1-9, instead of 0). Dividing that number by 10 gets you close to the Bin number, but with a decimal. Adding 1 to this number makes the Bin number start at 1 instead of 0. The INT function removes the decimal. If you want to see each part in action, try this query: SELECT [Julian Date], datepart('y', [Julian Date]) as TheJulianDay, datepart('y', [Julian Date]) - 1 as TheJulianDayMinus1, (datepart('y', [Julian Date]) - 1) /10 as TheJDDiv10, ((datepart('y', [Julian Date]) - 1) /10) + 1 as TheJDDiv10Plus1, int((datepart('y', [Julian Date]) - 1) /10) + 1 as Bin FROM [TheTable] I love MS Access. I am such a geek. I hope this helps.

cahudak at Amazon Askville Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.