I am using relation SQL as a source for my query as below
select * from table where date = ?
what I need is when the user runs the report, it should prompt to date parameter. the default date should be the current date and there should be a calendar to select the date.
i am not using any universal here, so don't know what to do?
I think this is going to be as close as you can get.
select *
from table
where date = #Prompt('Enter Date:','D',,Mono,Free,Not_Persistent,,User:0)
Today's date is defaulted, but not selected. Be cautious with clicking on "Now". That will give you today's date with the current system time which is likely not what you want. You could convert your #Prompt function result to a datatype that does not include the time if you want users to be able to click "Now". In my opinion it is simple enough to instruct users to click the highlighted date for today's date.
Related
I want to schedule the mailing of a Cognos report, always using the current date. So, for example: today, I want to e-mail the report with data up until the 28th, but tomorrow it should contain data up until the 29th.
How can I achieve this?
Thanks in advance!
If you're expecting code, you didn't provide enough information, but let me try...
Assuming the "date" data against which you want to filter is in a query item named [Date] which is in a query subject named [Time] which is in a namespace named [namespace], create a filter like this:
[namespace].[Time].[Date] = current_date
If you want up to the current date which includes the days leading up to it you can use what dougp posted slightly modified.
[namespace].[Time].[Date] <= current_date
to ensure the where clause is pushed down to the database, I personally like to use a macro for current_date. So the expression becomes
[namespace].[Time].[Date] <= # timestampMask ( $current_timestamp , 'yyyy-mm-dd' ) #
Have done a lot of search before asking this question, like How to convert a string into date format, How to convert a string into date, but still can't figure it out.
So, here's the question, how to convert these string dates into date in Oracle:
"2016-08-15 10:45:30" (String type) -> 20160815 (Date type)
"20160815104530" (String type) -> 20160815 (Date type)
Any idea will be appreciated.
You are mixing two things here:
The first is the conversion of a String data type, in Oracle VARCHAR2 into a DATE data type.
The DATE data type has a precision of seconds, you can't change that. A DATE data type will always give you the date and time component, i.e year, month, day, hours, minutes and seconds: Oracle SQL Data Type Documentation
However, the second part of what you are asking is about how to format the date when retrieved. This is helpful when running reports, or other kinds of visual display of dates. For example, in the US you would most likely want your date columns appear in the format MM/DD/YYYY while everywhere else in the world you most likely want to stick with DD/MM/YYYY. Oracle lets you do that by telling it what NLS_DATE_FORMAT you want to use. You can set that parameter for each individual session as well as on database level, it is up to you (and your DBA) to decide where and when you want to set that. In your case you can apply this via the ALTER SESSION command:
SQL> ALTER SESSION SET nls_date_format='YYYY-MM-DD';
Session altered.
SQL> SELECT TO_DATE('2016-08-15 10:45:30', 'YYYY-MM-DD HH24:MI:SS') FROM DUAL;
TO_DATE(
----------
2016-08-15
SQL> SELECT TO_DATE('20160815104530', 'YYYYMMDDHH24MISS') FROM DUAL;
TO_DATE(
----------
2016-08-15
You use to_date():
select to_date(substr(str1, 1, 10), 'YYYY-MM-DD')
select to_date(substr(str2, 1, 8), 'YYYYMMDD')
In plain SQL (in my case: sqlite), I would be able to query for a specific date in a DATE column as follows:
SELECT * FROM table WHERE date(dateColumn) = '2015-01-01'
This works because the date() function cuts off the time part of the DATE value.
Can I do something similar with Predicates in Core Data? Or do I have to use something where I determine the start and end of that day and then look for dates between the two date values?
I have a query expression in Cognos where I need to compare a past date to the current date. I don't see one in the functions list and I'm otherwise unsure how to put the query date inside a query object.
How can I use the current date in a query?
Depending on your Database software, the object will be either be current_date (SQL Server) or SYSDATE{} (Oracle). If you don't know which you have, just make an expression of just the function and press the Validate button; if you get an error, you used the wrong function for your database.
You can then use this object like any other Date query object, so you can add/compare it to dates in your query or display it somewhere on the page.
The best way is to use current_date. This method is data source agnostic and will be converted to the appropriate data source equivalent at run-time.
You can use something like this with your query:
SELECT
FIELD1
FROM TABLE
WHERE
FIELD2 = current_date
Asumming that FIELD2 has a date format
I created a Date and Time column in a Sharepoint list called EventDate. According to Microsoft documentation the Date and Time column maps to the System.DateTime type.
Now I'm seeing an error message when I try to insert the following date into that column:
Date: 1/1/1800
Error message:
"Invalid date/time value.
A date/time field contains invalid data. Please check the value and try again."
I also tried to use set DateTime.MinValue and I receive the same error message. But if I insert a more recent date like 1/1/1900 it works fine.
Does Sharepoint have a limitation of the minimum value of a Date and Time field?
I found out that if you try to insert the value 1/1/1800 in a Sharepoint Date and Time field manually (using Sharepoint forms) you receive this error:
"You must specify a valid date within the range of 1/1/1900 and 12/31/8900."
Therefore, Sharepoint only accepts values between 1/1/1900 and 12/31/8900.
There is no obvious reason as to why SharePoint limits the storage of the datetime datatype as it does now.
In SQL Server, the smalldatetime columns allows date in the range from 1/1/1900 - 6/6/2079 and the datetime columns are ranged 1/1/1753 - 12/31/9999
So there's no range from 1/1/1900 - 12/31/8900 and I haven't got the slightest idea why the limitation exists.
To make things even worse: SQL SErver 2008 has a smalldatetime2 and datetime2 type (the really just added a 2 to the name :/) wich allows any date (1/1/0000 - 12/31/9999) but even SharePoint 2010 on a SQL 2008 has the same limit
And Kit: using a single line of text is a very poor substitu, as there is no way to validate the values entered by the user
You could try creating a custom field to store the datetime value.
see http://msdn.microsoft.com/en-us/library/gg132914.aspx