Cognos not filtering by date correctly - cognos-10

I have a calendar table on my database that looks like this:
calendar_date first_day_in_week
2013-01-01 00:00:00.000 2012-12-31 00:00:00.000
2013-01-02 00:00:00.000 2012-12-31 00:00:00.000
2013-01-03 00:00:00.000 2012-12-31 00:00:00.000
2013-01-04 00:00:00.000 2012-12-31 00:00:00.000
2013-01-05 00:00:00.000 2012-12-31 00:00:00.000
2013-01-06 00:00:00.000 2013-01-07 00:00:00.000
I want to get a list of first days of the week for a given date range. I set up two parameters in cognos, StartDate and EndDate and am using this expression to filter my data:
[Business View].[Calendar].[calendar_date] between cast(?StartDate?, date) and cast(?EndDate?, date)
But when I run the report for, say, the range of 11/1/2015 to 11/24/2015, I get "No Data Available". But if I run if for the date range of 11/1/2015 to 11/1/2015, I get a result. What exactly am I doing wrong here?

Related

Update year only in column timestamp date field SQLITE

I want to update the year only to 2025 without changing the month day and time
what I have
2027-01-01 09:30:00
2012-03-06 12:00:00
2014-01-01 17:24:00
2020-07-03 04:30:00
2020-01-01 05:50:00
2021-09-03 06:30:00
2013-01-01 23:30:00
2026-01-01 08:30:00
2028-01-01 09:30:00
what i required is below:
2025-01-01 09:30:00
2025-03-06 12:30:00
2025-01-01 17:24:00
2025-07-03 04:30:00
2025-01-01 05:50:00
2025-09-03 06:30:00
2025-01-01 23:30:00
2025-01-01 08:30:00
2025-01-01 09:30:00
I am using dB Browser for SQLite
what i have tried but it didn't worked
update t set
d = datetime(strftime('%Y', datetime(2059)) || strftime('-%m-%d', d));
You may update via a substring operation:
UPDATE yourTable
SET ts = '2025-' || SUBSTR(ts, 6, 14);
Note that SQLite does not actually have a timestamp/datetime type. Instead, these values would be stored as text, and hence we can do a substring operation on them.

Duplicate NETCDF data values across timesteps using R

I have 6-hourly data and will like to 'duplicate' it to hourly data.
The first 6-hour timestep starts on 2017-01-01 00:00:00 and the next 6-hour timestep starts on 2017-01-01 06:00:00. I would like to copy the value of 2017-01-01 00:00:00 and assign it to the next 5 time steps and so on ...
The outpout should follow this pattern (illustration only):
Date Time Value
2017-01-01 00:00:00 0.00012120
2017-01-01 01:00:00 0.00012120
2017-01-01 02:00:00 0.00012120
2017-01-01 03:00:00 0.00012120
2017-01-01 04:00:00 0.00012120
2017-01-01 05:00:00 0.00012120
.
.
.
2019-12-01 00:00:00 0.0024270
2019-12-01 01:00:00 0.0024270
2019-12-01 02:00:00 0.0024270
2019-12-01 03:00:00 0.0024270
2019-12-01 04:00:00 0.0024270
2019-12-01 05:00:00 0.0024270
.
.
.
Do the same for the next 6-hour timestep which is 2017-01-01 06:00:00 in the attached file.
Assume that the hourly rainfall remains constant during the 6h period. Thus, each hour in the 6h period has the same rainfall value.
Sample NETCDF data are found here
First create 5 NetCDF files with the time shifted by 1, 2, 3, 4 and 5 hours:
cdo -shifttime,1hour testing.nc testing1.nc
cdo -shifttime,2hour testing.nc testing2.nc
cdo -shifttime,3hour testing.nc testing3.nc
cdo -shifttime,3hour testing.nc testing4.nc
cdo -shifttime,4hour testing.nc testing5.nc
Then merge them using mergetime:
cdo mergetime testing*.nc out.nc

Select records within the time range

I would like a help ... the clinic has several doctors and each one has a specific time of care. Example: 07:00 to 12:00, 12:00 to 17:00, 09:00 to 15:00 ... What is the SQL statement to display only records within the specified time range in the start_time and end_time ?
fields:
start_time | end_time
07:00:00 | 12:30:00
09:00:00 | 15:00:00
12:30:00 | 17:00:00
07:00:00 | 17:00:00
That is, in the morning, display only the records that are part of 07:00:00 to 12:30:00 from the current time. If it's afternoon show only record that are part of 12:30:00 until 17:00:00.
Thankful.

How to change to Year Month Week format?

I have dates in year month day format that I want to convert to year month week format like so:
date dateweek
2015-02-18 -> 2015-02-8
2015-02-19 -> 2015-02-8
2015-02-20 -> ....
2015-02-21
2015-02-22
2015-02-23
2015-02-24 ...
2015-02-25 -> 2015-02-9
2015-02-26 -> 2015-02-9
2015-02-27 -> 2015-02-9
I tried
data$dateweek <- week(as.POSIXlt(data$date))
but that returns only weeks without the corresponding year and month.
I also tried:
data$dateweek <- as.POSIXct('2015-02-18')
data$dateweek <- format(data$dateweek, '%Y-%m-%U')
# data$dateweek <- format(as.POSIXct(data$date), '%Y-%m-%U')
but the corresponding columns look strange:
date datetime
2015-01-01 2015-01-00
2015-01-02 2015-01-00
2015-01-03 2015-01-00
2015-01-04 2015-01-01
2015-01-05 2015-01-01
2015-01-06 2015-01-01
2015-01-07 2015-01-01
2015-01-08 2015-01-01
2015-01-09 2015-01-01
2015-01-10 2015-01-01
2015-01-11 2015-01-02
You need to use the '%Y-%m-%V format to change it:
mydate <- as.POSIXct('2015-02-18')
> format(mydate, '%Y-%m-%V')
[1] "2015-02-08"
From the documentation strptime:
%V
Week of the year as decimal number (00–53) as defined in ISO 8601. If the week (starting on Monday) containing 1 January has four or more days in the new year, then it is considered week 1. Otherwise, it is the last week of the previous year, and the next week is week 1. (Accepted but ignored on input.)
and there is also (The US convention) :
%U
Week of the year as decimal number (00–53) using Sunday as the first day 1 of the week (and typically with the first Sunday of the year as day 1 of week 1). The US convention.
It really depends on which one you want to use for your case.
mydate <- as.POSIXct('2015-02-18')
> format(mydate, '%Y-%m-%U')
[1] "2015-02-07"
In your case you should do:
data$dateweek <- format(as.POSIXct(data$date), '%Y-%m-%U')

reshaped date from month end to chronological

I have some data like
Date col A col B col C .......
01/31/2008 00:00:00.000
01/31/2009 00:00:00.000
01/31/2010 00:00:00.000 bunch of data
01/31/2011 00:00:00.000
01/31/2012 00:00:00.000
01/31/2013 00:00:00.000
02/28/2008 00:00:00.000
02/28/2009 00:00:00.000 in these columns
02/28/2010 00:00:00.000
02/28/2011 00:00:00.000
02/28/2012 00:00:00.000
02/28/2011 00:00:00.000
03/31/2008 00:00:00.000
03/31/2009 00:00:00.000
03/31/2010 00:00:00.000
03/31/2011 00:00:00.000
03/31/2012 00:00:00.000
03/31/2013 00:00:00.000
.
.
.
I need them rearranged so that it looks likes
Date col A col B col C .......
01/31/2008 00:00:00.000
02/28/2008 00:00:00.000
03/31/2008 00:00:00.000 corresponding data
04/30/2008 00:00:00.000
05/31/2008 00:00:00.000
.
.
.
ie right now its month end, I just need them in sequential order any idea how to do this, you can assume there are 6 per date and 12 dates from jan to dec. Thanks.
This might help:
df <- df[with(df,order(Date)),]

Resources