I have an Excel worksheet that I have the data pulled from a Historian database for emission tags in a Wonderware server. I need to know how i can write the SQL query that uploads data between two date ranges.starte date end date.
I have collected the data and display I want, I just dont know how I can implement between two date ranges the user types in on another form. I DONT KNOW HOW TO DO THIS.
I have tried nothing because im not sure how to implement a parameter query with excel.
SET QUOTED_IDENTIFIER OFF
SELECT * FROM OPENQUERY(INSQL, "SELECT DateTime, [AB01_PE01], [NU_DC01_DX01_DISPLAY],
[NU_DC01_DX02_DISPLAY], [NU_DC02_DX01_DISPLAY], [NU_DC02_DX02_DISPLAY],
[NU_DC03_DX01_DISPLAY], [NU_DC03_DX02_DISPLAY], [NU_DC05_DX01_DISPLAY]
FROM WideHistory
WHERE wwRetrievalMode = 'Cyclic'
AND wwCycleCount = 14
AND wwVersion = 'Latest'
AND DateTime >= '20190501 06:00:00.000'
AND DateTime <= GetDate()")
what I want is where Datetime >= is I need to set up where it ask the user the start date and end date? I do not know how to do this in excel I am new to the historian add in.
Based on your comment response, I understand your real question is: how to parameterize SQL query in Excel. This video shows step by step guide to do that: https://youtu.be/xPalEw4xw1w?t=129
Related
I am a newbie in fullstack development. I am doing my first project using postgresql, nodejs and express(ejs template). In my task list project i have a duedate option, where i enter a duedate(date picker) for a task and it get saved in the postgres database. I have an edit option aswell with a datepicker. how can i retreive the date in the 'dd/mm/yyyy' format from the database and display it inthe date picker in the edit page?.is it possible. Please help.
Thanks
What gets stored in the DB for date will probably look different then what you see on the front-end, simply because date / time is usually stored as UTC etc ( this will depend on how you have the table configured)
Next, you can use javascript built in date function like toLocaleDateString('en-US') to get a mm/dd/yyyy format from the stored date in the DB
What this means is that on the front-end you would pull the date from the DB as normal, then for the date-picker you would just pass the date over like
let myDate = new date([date from db); // this create a new date object off the date from the DB
//Now we make is a readable date
// myDate = myDate.toLocaleDateString('en-US'); // will give mm/dd/yyyy
I created a report with a StartDate and EndDate parameter. If I want to see the information for a single day, I use the same Date in both parameters. I now want to create a subscription for this report so that it runs everyday. How can I use the current date and pass it to these parameters when the report runs? Thanks!
Step 1: You will have your defaultDates dataset as so. can be query or you can wrap it as a Stored proc.
Select TodaysDate = cast(getdate() as date)
Step 2: then , under default values for both the params you will anchor get value from dataset and point to this dataset, which is defaultDates.
Step 3: test it locally. Make sure to delete .DATA from your working directory to enforce fresh data.
Step 4: build and deploy to whatever test location.
EDIT: This will only work with Enterprise edition.
First, write a query that gets the current date and formats it to match the VALUE in your parameter (for example, is it DD-MM-YYYY, YYYY-MM-DD?). Make sure to name your column something meaningful like "CurrentDate".
select cast(current_timestamp as date) as CurrentDate
Then create a new subscription for your report. Instead of Standard Subscription, choose data driven subscription. Now select your SQL datasource and paste in your query. Press validate to make sure it runs fine. Hit OK.
Now you can go down to your subscription parameters at the very bottom of the page. Set Source of Value to be "Get value from dataset" then pick your "CurrentDate" from the drop down.
That's it, data driven subscription with current date.
I have an date property for which I have created an document property as StartDate and EndDate, and in SQL query the same will be used to filter. In the Text Area , I am using it as Control Type: INPUT Field as this has two different values for start date and end date (as shown in fig: ), I need to merge this two date property into single Slider Control Type. I tried to use Functions using formula "First(DateProperty)". However I am not successful . Can someone help me on this?
I just found the reason for the issue as well, below are two points. i May be wrong as well:
1) To create an slider calendar, we need to create a function. This function will show the data tables which are of from different connections and In our analysis we have single connection and table for Each components .Due to this we are getting error called Cyclic Dependencies and Function is not working.
2) Next to create a simple table having only date property also causing problem as even this should be an Imported table and not linked to the external databases.
I used http://toedter.com/ jDateChooser to get the date from user. But now I want to reset the selected date to the calendar from SQL database. This is the code I wrote to put selected date to database.
pst.setString(5, ((JTextField)datead.getDateEditor().getUiComponent()).getText());
I figured it out myself.
java.util.Date dateadx = new SimpleDateFormat("yyyy-MM-dd").parse(dateadm);
Here dateadm is the String variable which you want to store as date in JDateChooser.
Then you can simply call
datead.setDate(dateadx)
to set the date.
I'm new to Orchard CMS and trying to create a query that will filter a list of upcoming events date. What I want to do is filter a list of upcoming events. I have set up a list and plan to use the creation date (setting the date to the event date) as filter. Where I have ran into an issue is getting the filter value to work. When I set the filter value to {DateTimeField.Date} for get the current date or any of the other date options, the filter does not work. It show all events. When I manually type in the value field "2014-08-20", it works. Any ideas of why I can not set the date to the current date?
I have also tried creating just a date field within the content definition and received the same issue as above. I do plan to create a Event End Date that will not show, but will be used to filter. I assume the value will be very similar though to what would be needed for the creation date though.
I am using Orchard CMS 1.8.0
Any help will be greatly appreciated.
The current date can be obtained in Token form like this: {Date}. That token itself can be modified as a date token. In particular, it can be formatted. In your case, because the filter will construct a HQL filtering clause from your expression, {Date.Format:yyyy-MM-dd} will put the current date into the right format.