Creating List Webpart: Ordering by Date field and Type - sharepoint-2007

I am trying to create a web-part to show items that relate to a certain field and are before an expiration date using a web-part in SharePoint 2007.
The list has a Title field, a URL field a Related field and an ExpireDate field.
So the list looks like this:
Title URL Related ExpireDate
Resolution http://blah Service 5/14/2013
Solution http://blah2 Records 9/14/2012
So if I need the items that are related to service today's date is before the expiration date I want it to display.
Do I need a calculated Column?

Ended up using a view where ExpireDate is greater than or equal to [Today] And RelatedField contains Service.

Related

I'm trying to create year parameter in tableau to filter data by year. The results are not getting reflected

I've created a parameter with values 1970-2013 range and have then created calculated field with the below code
[Year] = [parameter year]
If you only want to filter by year, then you don’t need a parameter or a calculated field. Just put the Year field on the filter shelf and show the filter control.
A parameter is useful in other circumstances, say if you want to treat one year differently, but keep all years in the viz
In Calculation field don't use " = "sign, just type parameter name only and click 'OK'.

writing jira query to find tickets where a set custom due date field has been set

I’m trying to set up a filter than returns all the tickets where a custom Due Date field has been set AND then changed to some future date. So I don't want to get tickets back that have gone from unset to set, just where the date has been changed again after being set to an initial date.
Seems I can't use the CHANGED parameter on date fields.

How to filter result based on birthdate and min/max age values in Parse?

I'm using the Parse iOS SDK. I want to filter users based on their specified age ranges.
I have two tables:
1st, tableUser which has a field titled birthdate with a String data type.
2nd, tableSettings which has two fields minAge and maxAge, both of which are Number types
I want to fetch users from the tableUser class who's age, calculated from birthdate field, falls between the age range specified in the tableSettings class. For example, if the minAge value is 20 and the maxAge value is 25, then I only want to retrieve users with an age between this range.
Is this possible? How would I make such a query?
Your requirement sounds non-trivial with that suboptimal data structure. I'd probably go for cloud code to hide the required logic from the app. This logic would be to query the tableSettings and calculate the date range that applies.
Now that you have this range, it's still hard to use because your other table uses a string representation of the date rather than a true Date type. This really sucks. If you can you should change the date to the correct type, or at least add another column with a correct representation of the date (but then you have to keep them in sync).
Working with dates you can add specific range criteria to your query and life is easy.
Working with strings is compounded in difficulty because you have the day first, so you can't even use BEGINSWITH to filter the query on year and then process the content. It really is a terrible data model for the problem. So this basically leaves you paging through everything doing an explicit conversion of the string to a date and then comparing that to the range.
If you at all can, change the data model. Even if you create a new class (table) specifically for this data and use an afterSave hook to keep them in sync.

Should date field in DW date-map be of Date data type or of String data type, if I want to put placeholders?

I have a date map (date dimension) like every other data warehouse.
The most obvious way to store date field in the date field is in date datatype. However, I want to keep some records in my date dimension which ID as negative values and the date field should give description of why this date is invalid.
For example, in my fact table, let's say I have a field called order_date_id which references the date dimension. However, for some records in the fact table, I want to say that the order_date was not recorded by the system and hence we can't use it. But I want it's entry present.
I thought that I would make an entry in the date dimension with ID=-1 and date = 'Date was not recorded'. But to use this kind of a placeholder, I will have to keep date as a string value. If I store it as a string value it will be very ineffective when I compare two dates.
Please advise a good practice.
I think you are confusing two things;
Date Dimension Design
Identification of Date not assigned by system
This is how I would design the date dimension
Date_id = number with yyyymmdd - intelligent key and this will be the primary key; this saves doing a lookup to the database to assign the id
Date - the actual date
Year - year
Month - Month (yyyy-mmm or yyyy-mmmm)
Month_Nbr - Month ( yyyy-mm )
Quarter - yyyy-Qn(1,2,3,4)
all the other attributes you need
if there are sales order which do not have a date assigned, assign them 19000101 and have them in your fact table...
if you incrementally keep getting sales order without dates, then I would consult the business and put in the 1st day of the month of when they are arriving into the system; this will be a more acceptable solution.

How would I store a date that can be partial (i.e. just the year, maybe the month too) and output it later with the same specifity?

I want to let users specify a date that may or may not include a day and month (but will have at least the year.) The problem is when it is stored as a datetime in the DB; the missing day/month will be saved as default values and I'll lose the original format and meaning of the date.
My idea was to store the real format in a column as a string in addition to the datetime column. Then I could use the string column whenever I have to display the date and the datetime for everything else. The downside is an extra column for every date column in the table I want to display, and printing localized dates won't be as easy since I can't rely on the datetime value... I'll probably have to parse the string.
I'm hoping I've overlooked something and there might be an easier way.
(Note I'm using Rails if it matters for a solution.)
As proposed by Jhenzie, create a bitmask to show which parts of the date have been specified. 1 = Year, 2 = Month, 4 = Day, 8 = Hour (if you decide to get more specific) and then store that into another field.
The only way that I could think of doing it without requiring extra columns in your table would be to use jhenzie's method of using a bitmask, and then store that bitmask into the seconds part of your datetime column.
in your model only pay attention to the parts you care about. So you can store the entire date in your db, but you coalesce it before displaying it to the user.
The additional column could simple be used for specifying what part of the date time has been specified
1 = day
2 = month
4 = year
so 3 is day and month, 6 is month and year, 7 is all three. its a simple int at that point
If you store a string, don't partially reinvent ISO 8601 standard which covers the case you describe and more:
http://en.wikipedia.org/wiki/ISO_8601
Is it really necessary to store it as a datetime at all ? If not stored it as a string 2008 or 2008-8 or 2008-8-1 - split the string on hyphens when you pull it out and you're able to establish how specific the original input was
I'd probably store the datetime and an additional "precision" column to determine how to output it. For output, the precision column can map to a column that contains the corresponding formatting string ("YYYY-mm", etc) or it can contain the formatting string itself.
I don't know a lot about DB design, but I think a clean way to do it would be with boolean columns indicating if the user has input month and day (one column for each). Then, to save the given date, you would:
Store the date that the user input in a datetime column;
Set the boolean month column if the user has picked a month;
Set the boolean day column if the user has picked a day.
This way you know which parts of the datetime you can trust (i.e. what was input by the user).
Edit: it also would be much easier to understand than having an int field with cryptic values!
The informix database has this facility. When you define a date field you also specify a mask of the desired time & date attributes. Only these fields count when doing comparisons.
With varying levels of specificity, your best bet is to store them as simple nullable ints. Year, Month, Day. You can encapsulate the display logic in your presentation model or a Value Object in your domain.
Built-in time types represent an instant in time. You can use the built in types and create a column for precision (Year, Month, Day, Hour, Etc.) or you can create your own date structure and use nulls (or another invalid value) for empty portions.
For ruby at least - you could use this gem - partial-date
https://github.com/58bits/partial-date

Resources