This commit is contained in:
2018-12-03 21:15:41 +00:00
parent 1eb03acf98
commit 0461ea3a9d

View File

@@ -51,7 +51,7 @@ namespace AyaNova.Biz
sb.Append(sColumn);
sb.Append(" ");
//handle null values separately
@@ -643,6 +643,83 @@ namespace AyaNova.Biz
sb.Append("'");
break;
//=======================
//NEW ONES FOR RAVEN
case FilterSpecialToken.LastQuarter:
//First determine what quarter we are in now, then get the date range for the quarter before that
switch(DateTime.Now.Month)
{
//are we in the first quarter?
case 1:
case 2:
case 3:
//Then we need the dates of the last quarter of last year
//From zero hour October 1st last year
dtAfter = new DateTime(DateTime.Now.AddYears(-1).Year, 10, 1, 00, 00, 00);
//To zero hour January 1 this year
dtBefore = new DateTime(DateTime.Now.Year, 1, 1, 00, 00, 00);
break;
//are we in the second quarter?
case 4:
case 5:
case 6:
//Then we need this year first quarter JAN-FEB-MAR
//From zero hour january 1 this year
dtAfter = new DateTime(DateTime.Now.Year, 1, 1, 00, 00, 00);
//To zero hour April 1 this year
dtBefore = new DateTime(DateTime.Now.Year, 4, 1, 00, 00, 00);
break;
//Are we in the third quarter?
case 7:
case 8:
case 9:
//Then we need this year Second quarter APR-MAY-JUN
//From zero hour April 1 this year
dtAfter = new DateTime(DateTime.Now.Year, 4, 1, 00, 00, 00);
//To zero hour July 1 this year
dtBefore = new DateTime(DateTime.Now.Year, 7, 1, 00, 00, 00);
break;
default:
//We're in the fourth quarter
//Then we need this year Third quarter JUL-AUG-SEP
//From zero hour July 1 this year
dtAfter = new DateTime(DateTime.Now.Year, 7, 1, 00, 00, 00);
//To zero hour Oct 1 this year
dtBefore = new DateTime(DateTime.Now.Year, 10, 1, 00, 00, 00);
break;
}
//From zero hour january 1 this year
dtAfter = new DateTime(DateTime.Now.Year, 1, 1, 00, 00, 00);
//To now
dtBefore = System.DateTime.Now;
sb.Append(">'");
sb.Append(PostgresDateFormat(dtAfter));
sb.Append("') AND (");
sb.Append(sColumn);
sb.Append(" ");
sb.Append("<'");
sb.Append(PostgresDateFormat(dtBefore));
sb.Append("'");
break;
case FilterSpecialToken.YearToDate:
//From zero hour january 1 this year
dtAfter = new DateTime(DateTime.Now.Year, 1, 1, 00, 00, 00);
//To now
dtBefore = System.DateTime.Now;
sb.Append(">'");
sb.Append(PostgresDateFormat(dtAfter));
sb.Append("') AND (");
sb.Append(sColumn);
sb.Append(" ");
sb.Append("<'");
sb.Append(PostgresDateFormat(dtBefore));
sb.Append("'");
break;
}
#endregion
@@ -858,6 +935,8 @@ namespace AyaNova.Biz
/// <returns></returns>
private static string PostgresDateFormat(DateTime theDate)
{
//TODO: Double check that this returns the date as an actual converted to UTC date and not just the local time in UTC format
//If this was used it should be like this for a UTC date to iso8601
// ISO8601 with 7 decimal places
return theDate.ToString("o", CultureInfo.InvariantCulture);