Qlikview - Calendar - fromDate and toDate - calendar

My calendar script is loading fine but the table not reflecting any changes.
Below the code i am using:
Calendar:
load Distinct
"sDate",
Year("sShipment Date") As PostingYear,
Month("sShipment Date") As PostingMonth,
Week("sShipment Date") As PostingWeekOnly,
WeekDay("sShipment Date") As PostingWeekDay,
Day("sShipment Date") As PostingDay,
'Q' & Ceil(Month("sShipment Date")/3) As PostingQuarter
resident myTable;
Temp:
Load
min("sDate") as minDate,
max("sDate") as maxDate
Resident Calendar;
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));
I create calendar object but when I pick the date I don't see change in my straight table.
I want when change start and end date to get result in my table between start and end date. Does anyone have an idea?

In your calendar properties use the field selection and use an expression.
=MonthName(sdate)
For example and then this will give you the full range to select from.
This will then reflect in your straight table.

Related

Lightning Flow Query

I am creating the lightning flow. In which, I need to provide the date in the 'field1' (Type : Date) in the screen component.
In the screen component, the 'field1' should only accept the date value which is in the range of 3years in the past of the current date and 2 years in the future of the current date.
For instance, if a user is entering the value in the 'field1' Date field on 5/13/2021 then the valid date range is between 5/13/2018 thru 5/13/2023.
Can anyone please guide/assist on how to achieve this.
Thanks in advance.
enter image description here
To create this date field you need to use following formula
IF(OR(
({!Accepted_Date} <= (DATE(YEAR({!$Flow.CurrentDate}) - 3,MONTH({!$Flow.CurrentDate}),DAY({!$Flow.CurrentDate}) - 1))), ({!Accepted_Date} >= (DATE(YEAR({!$Flow.CurrentDate}) + 2,MONTH({!$Flow.CurrentDate}),DAY({!$Flow.CurrentDate}) + 1)))
), false, true
)

How to find the specific record using sub query in SQL

I have a table in my Database in which Electronics part number information is saved. Against each part number, a Datasheet is attached with the Pdf file name and with its Publication date in next column.
There are some parts where pdf with different publication date is attached and I want to find out the Latest publication date pdf file.
Below is the code that I applied:
(
select v_prt_nbr_spr, max(s_gph_co_date), s_gph_file_name
from export1
where v_prt_nbr_spr = '747845-4'
group by v_prt_nbr_spr, s_gph_file_name
)
But I am getting multiple Pdf file name instead of the latest date as I am using group by clause..
Output:
v_prt_nbr_spr s_gph_co_date s_gph_file_name
747845-4 01-07-2001 TYELD00008.pdf
747845-4 14-03-2011 TYELS72963.pdf
747845-4 04-03-2016 TYEL-S-A0001601863.pdf
I want only TYEL-S-A0001601863.pdf name to show as it is the latest date pdf file.
You can try this:
select top 1
v_prt_nbr_spr, s_gph_co_date, s_gph_file_name
from export1
where v_prt_nbr_spr = '747845-4'
order by s_gph_co_date desc

add x number of working days to date

I am trying to find the date after specific number of days.
My query looks like this:
UPDATE [PST].[dbo].[tbl_Project_tracker1]
SET Predicted_Eng_Comp_date = tb2.Predicted_Eng_Comp_date
FROM (SELECT NETWORK_NO,
dateadd(DAY, 20, Actual_Eng_Start_date) as Predicted_Eng_Comp_date
FROM [PST].[dbo].[tbl_Project_tracker1]
) as tb2
WHERE [NETWORK_NO] = tb2.[NETWORK_NO]
The query works fine but i am looking for working days. How do i calculate that?
Please make use of below Query (Which replaces your current query):
UPDATE [PST].[dbo].[tbl_Project_tracker1] SET Predicted_Eng_Comp_date = DATEADD(DAY, 20, Actual_Eng_Start_date)

Importing Dates into R from SQL Server

I am trying to query a SQL Server database to check for the MAX date in one field and to select the next day for input into another process. I am able to query the database and pull back a date, but I can't convert it into a date object.
Here is what I tried:
tmpMaxDate <- sqlQuery(dbhandle, 'select MAX([date]) + 1 from dbo.My_Data ')
tmpMaxDate
1 2016-01-02
IsDate(tmpMaxDate)
[1] FALSE
maxDate <- as.Date(tmpMaxDate)
Error in as.Date.default(tmpMaxDate) :
do not know how to convert 'tmpMaxDate' to class “Date”
maxDate
NULL
IsDate(maxDate)
[1] FALSE
maxDate <- as.Date(tmpMaxDate, format = "%Y-%M-%D")
Error in as.Date.default(tmpMaxDate, format = "%Y-%M-%D") :
do not know how to convert 'tmpMaxDate' to class “Date”
IsDate(maxDate)
[1] FALSE
maxDate
NULL
The packages I am using are RODBC, chron, lubridate, and RSQLserver
I thought I needed to convert to a date object to use the date from SQL Server in R.
Any thoughts on why my date won't convert? Do I need to convert to be able to use that date to filter data in R?
DateVar <- sqlQuery(dbhandle,"SELECT CONVERT(varchar(10),GETDATE() + 1,101) as Date")
DateVar
NewDate <- as.Date(DateVar$Date, format = "%m/%d/%y")
NewDate
I think the trick for me to was give the date response a column name and then reference the column (being the specific string value needed to convert) name in the conversion.
class(NewDate)
will show as "Date"

Sybase dataadd time where time added is the difference of 2 times

I have a sybase database and would like to create a new bigdatetimefield by adding time to a current bigdatetimefield
for example
I have a date1 field = 8/31/2015 2:23:49.529000 PM
I have a date2 field = 8/31/2015 7:23:49.529000 AM
I have a mainDate field = 8/31/2015 2:24:46.112000 PM
I would like to make a new field that is the mainDate field minus the difference in time between the date1 field and the date2 field
So in this case the new filed would be 8/31/2015 2:24:46.112000 PM - (8/31/2015 2:23:49.529000 PM - 8/31/2015 7:23:49.529000 AM)
Any idea how to do that in sybase?
SELECT new_dt = DATEADD(ss, datediff(ss,date1,date2),mainDate)
FROM my_table
That's only accurate to seconds though. You can use millisecond or microsecond.

Resources