Browsing the year in a string - visual-foxpro

So I have a field containing dates; however not all years are the same. How do I browse for a specific year. I have tried the following, but it doesn't really work.
BROWSE FIELDS Lastcall FOR Lastcall LIKE '%2019%'
thanks in advance

OR.. exactly as you had it which will allow you to directly edit the records too. IF the "LastCall" is a date based field
BROWSE FIELDS Lastcall FOR year( Lastcall ) = 2019
if it is a string field, you could do
BROWSE FIELDS Lastcall FOR '2019' $ Lastcall
The "$" means does the string on the left exist anywhere in the field on the right (which you could concatenate multiple string fields if you so wanted to.

There's a number of ways you could do this.
Set a filter on the table:
SET FILTER TO YEAR(LastCall) = 2019
Use a select query:
SELECT * FROM TableName WHERE YEAR(LastCall) = 2019
If your table is really large I would suggest using the select statement.

Related

Spreadsheet - query-importrange sort by date and keep text in the same column

I am using 3 different spreadsheets which i have linked to a third spreadsheet where it shows up specific columns shorted by date asc (col2). The problem is that in the initial spreadsheets (where i importing the data from) the col30 (which i am trying to sort as col2 in final spreadsheet) has dates and text. What i need is that in the final spreadsheet to have the date sorted and to show also the text (in the col2 of final spreadsheet-which imports data from col30 of the 3 different spreadsheets).
The dates are sorted but neither the text appears nor the rest of the data which are in the same row with the date (on initial spreadsheets). The total data of the columns chosen when "Col6 CONTAINS '"&$B$1&"' are only appears when i put a date on col30 on initial spreadsheets. Otherwise, when it is no date but onlly text on col30 it doesn't return any variables.
Any suggestions? Thank you in advance.
What i have tried so far, which works without showing the text that i need to be shown:
=QUERY(QUERY({IMPORTRANGE("url1 ";"sheet1!A2:AJ1000");IMPORTRANGE("url2 ";"sheet2!A2:AJ1000");IMPORTRANGE("url3 ";"sheet3!A2:AJ1000")};"Select Col5,Col30,Col31,Col21,Col22,Col23,Col24,Col34,Col35,Col36 where Col6 CONTAINS '"&$B$1&"'");"Select * where Col2 is not null order by Col2")
Here is what I believe you are trying to achieve:
=QUERY(
{
IMPORTRANGE("1usAXftvFrpCHz7LN43avWrWqSIO14iKM-pgwuG9jMeE";"Sheet1!A2:AJ")\
ARRAYFORMULA(
TO_TEXT(
IMPORTRANGE("1usAXftvFrpCHz7LN43avWrWqSIO14iKM-pgwuG9jMeE";"Sheet1!AD2:AE")
)
)
};
"SELECT Col5,Col37,Col38,Col21,Col22,Col23,Col24,Col34,Col35,Col36 WHERE Col6='"&$B$1&"' AND Col37 is not null ORDER BY Col30, Col31"
)
Let's unpack the changes:
Remove the outer query. You don't need it. Instead add the condition and order by in the first query.
change the range to be an open ended one
Add columns with the text version of the dates / times.
The last point is important as query only supports a single type at a time. This means that when you were querying over the date and time, you were loosing the text (because they are of another type). Adding 2 more columns and forcing them to be text allows you to add them in the result without loosing information and keeping the originals allows you to order by them.
References
QUERY (Docs editors help)
TO_TEXT (Docs editors help)
ARRAYFORMULA (Docs editors help)

Pig - Filter a column twice in the same filter

I'm trying to filter the same column twice. I basically want to only get the record in which one column is between the values of other 2 columns.
Imagine this:
(id,year_min,year_max,year)
(4470,1999,2001,2011)
(4471,2006,2013,2013)
So filtering like this it doesn't work:
filter1 = filter set by (year_min <= year and year_max >= year)
Is there another way of filtering it instead of breaking that filter into several ones?
Also, all the columns are bytearray.
PS: That is not the whole set but that is basically what I want to achieve.
Thanks.
I guess the year_max and year got swapped in your schema. It should be like this right? id, year_min, year, year_max but your schema says id, year_min, year_max, year . I modified the schema its works fine for me. Can you check it?

How to sort prompt values in a Webi report?

I have prompt for Fiscal Month in my Webi Report. I want to custom sort it so that the month starts with April, May, June , etc.
How is this possible?
Thanks
Niki
I tried many ways like adding LOVs and managing to sort the values at prompt, etc. But in BO 4.1, How we should do is,
1.Click on Parameters and List of Values.
In Edit SQL write the query with order by so that we get the order. for eg. select distinct fiscal_month,fiscal_month_number from calender_table order by fiscal_month_number.
Validate the query.
In Properties tab, check for hiding fiscal_month_number and give a appropriate name for fiscal_month column.
Now in Business Layer, select the dimension we created for fiscal_month, in Advanced Tab, add the List of Value that is created.
Thanks
Niki

Crystal Reports - Sorting two different date fields chronologically

I've got two date fields from two tables and I'm trying to show receipts of POs in line with work order consumption sorted chronologically.
Is there any way to sort two date fields together?
For instance:
1/1/14 work order date
1/5/14 work order date
1/7/14 PO receipt date
1/9/14 work order date
1/20/14 work order date
The two fields are 'duedate' from table 'porel' and 'reqdate' from table 'jobmtl'
Usually the simplest solution in such cases is to perform the ordering at the server side (e.g. using SQL Server stored procedure, Access query, etc.), and then use the stored procedure or query as the source for the data.
An alternative that I read about is to create global variables in the report, assign your dates values to these variables using 'WhilePrintingRecords;' in formula fields, and using these variables that then does the actual reporting for you.
Slightly complicated.
Another solution which I am not sure if applies to you is :
Click on the main menu > Report > Record Sort Expert
Select your date field in the box on the left and add it to the box on the right
Check the Ascending checkbox and click Ok
Let us know how it goes.
you should create a formula saying
if (table1.duedate = null) then
{table2.duedate}
else
{table1.duedate}
Then sort on this formula. Check the syntax yourself.

seeking syntax for date in where clause in Jet OLEDB

I have a problem of using the where clause for limiting dates
I can't even get a simple statement like on "Feb 5 2010" to work,
e.g.,
select * from LineItems where DueDate = 2/5/2010;
I tried
"2/5/2010"
"2010/2/5"
"2010-2-5"
"2010-02-05"
2010-2-5
2010-02-05
...
but none worked.
Does anyone have an idea what the proper format for the date should
be? And should it be quoted?
Thank You!
This works for me in a Query
SELECT *
FROM Table1
where mydate = 2010/2/5
Writing a date like that is unambiguous; the other way round will depend on your locale settings.
Hey Guys, I did figured out that you must surround the date with a pair of #'s. Just leaving the date unsurrounded does not work for me. I figured this out by saving a "Filter" in the Data View of Access as query, then I looked at that query in SQL view.

Resources