logo
down
shadow

Rearrange Date filter in stored procedure


Rearrange Date filter in stored procedure

By : Prateek Khandelwal
Date : October 18 2020, 06:10 AM
will be helpful for those in need I have a stored procedure in which I'm selecting couple of columns on the basis of date column provided. The result should be based on current financial year which starts with the 5th of January. , If you never run in the first five days of the year:
code :
select SUM([RetailPrice]) AS Retail,
       SUM([CostPrice]) AS Cost,
       SUM([MarketPrice]) AS Market
from PriceDetail
where [UserID] = 0029 and
      [Date] >= datefromparts(year(getdate()), 01, 05);
where [UserID] = 0029 and
      [Date] >= datefromparts(year(dateadd(day, -5, getdate())), 01, 05);


Share : facebook icon twitter icon
Comparing an asp.net date passed as a parameter to stored procedure with a date in database

Comparing an asp.net date passed as a parameter to stored procedure with a date in database


By : remlap42
Date : March 29 2020, 07:55 AM
hop of those help? I've tried to compare a date passed as parameter to a stored procedure from asp.net with a date in database. But cannot yield the needed result.. , The correct way to do this is
code :
@date datetime

Select * from table          
where [date] = @date
Select * from table          
where DATEPART(YEAR, [date]) = DATEPART(YEAR, @date)
and DATEPART(MONTH, [date]) = DATEPART(MONTH, @date)
and DATEPART(DAY, [date]) = DATEPART(DAY, @date)
How to un trim the date in vb6 (milliseconds must appear). The date is coming from stored procedure in sybase

How to un trim the date in vb6 (milliseconds must appear). The date is coming from stored procedure in sybase


By : Jerry Guo
Date : March 29 2020, 07:55 AM
this will help An adDBTimeStamp field is not a VB Date type. By blithely assigning its value to a Date variable you have converted it, truncating it to fit.
See How To Get Fractions of a Second from ADO adDBTimeStamp Field.
call a stored procedure from another stored procedure and bring values from first stored procedure to the second stored

call a stored procedure from another stored procedure and bring values from first stored procedure to the second stored


By : Pierre Langlois-Lace
Date : March 29 2020, 07:55 AM
will be helpful for those in need You just need to add the same parameters to sp_Insert_delivery and pass them in.
code :
Create proc sp_master
 @DeliveryID int, @FreightID int, @NoOfGoods int
as
--Perform reads and logic
begin
EXECUTE sp_Insert_delivery @DeliveryID, @FreightID, @NoOfGoods
end
Create proc sp_Insert_delivery
  @DeliveryID int, @FreightID int, @NoOfGoods int
as
begin try
insert into dbo.Delivery
(FreightID, DeliveryID, NoOfGoods)
Values
(@FreightID, @DeliveryID, @NoOfGoods)
end try
--followed by catch
find latest date between created date and updated date in sql stored procedure

find latest date between created date and updated date in sql stored procedure


By : user2603084
Date : March 29 2020, 07:55 AM
it helps some times I have two column in my table as created date and updated date.I want to find latest date from that.which ever is latest I want to considered that and filter it from input values.
code :
SELECT *
FROM Emp E
WHERE (E.USERID = @UserID)
    AND 1 = CASE 
        WHEN E.CDATE >= E.UDATE
            THEN CASE 
                    WHEN (
                            E.CDATE >= @FromDate
                            AND E.CDATE <= @ToDate
                            )
                        THEN 1
                    END
        WHEN E.CDATE < E.UDATE
            THEN CASE 
                    WHEN (
                            E.UDATE >= @FromDate
                            AND E.UDATE <= @ToDate
                            )
                        THEN 1
                    END
        ELSE 0
        END
pl/sql stored procedure to select from a table where date is equal to stored procedure parameter

pl/sql stored procedure to select from a table where date is equal to stored procedure parameter


By : user3680193
Date : March 29 2020, 07:55 AM
will help you The simplest option to make this query return data in data grid is to ... well, run it outside of the stored procedure. Procedures are nice, but not that nice for doing what you want.
When returning something, a function might be a better choice. For example:
code :
SQL> create or replace FUNCTION f_test (par_deptno in number)
  2    return sys_refcursor
  3  is
  4    l_rc sys_refcursor;
  5  begin
  6    open l_rc for
  7      select empno, ename, job, sal
  8      from emp
  9      where deptno = par_deptno;
 10    return l_rc;
 11  end;
 12  /

Function created.
SQL> select f_test(10) from dual;

F_TEST(10)
--------------------
CURSOR STATEMENT : 1

CURSOR STATEMENT : 1

     EMPNO ENAME      JOB              SAL
---------- ---------- --------- ----------
      7782 CLARK      MANAGER         2450
      7839 KING       PRESIDENT       5000
      7934 MILLER     CLERK           1300


SQL>
Related Posts Related Posts :
  • T SQL Select only first record for each day
  • SQL group and order
  • How can convert 15000000.00 to 15,000,000 in SQL server?
  • Can you tell me what this SQL would do?
  • AND vs OR in T-SQL
  • Slowness at Indexed View for SQL 2005
  • check for commonly used passwords on SQL Server
  • Find average revenue by each subcategory of top 5 categories in terms of quantity sold in vba sql
  • Improve performance of multiple insert and update queries
  • Column as a subquery
  • How to schedule a google-bigQuery so its results would import to spreadsheet on a daily basis?
  • ALTER TABLE takes forever even for a very little table
  • how to convert/calculate nvarchar to int
  • Spooky query behavior : Same query, different results when inside a view
  • Converting varchar to numeric nightmare
  • How to exclude certain combination pattern in data set?
  • Get results with wildcard
  • How to only select the SQL row with the MAX id in this join?
  • Converting a String with Length of Time into Different DataType
  • what does square brackets in an sql update statement mean?
  • CASE on WHERE CLAUSE SQL
  • Replacing value inside column
  • Weekly Schedule with SQL
  • How to choose minimum value row in Group By sql
  • Creating empty integer/decimal column by using Select
  • SQL string driving me crazy
  • summarize dates from a list of dates
  • Last 10 weeks in SQL Server
  • How to store less than / greater than in database
  • find number that is not 0 in a varchar sequence like 0000000001 or 00000123131
  • SQL query to fill multiple needs with partial quantities by using Oracle SQL window functions
  • SQL Server line break for CSV
  • I need to select clients who have multiple records in one column
  • How to group database column?
  • Getting a specific output from 2 tables
  • How to query different tables for data in order
  • About subquery in T-SQL
  • Memory Buffer pool taken by a Table
  • SQL : ORA-00906: missing left parenthesis
  • Data Conversion error while inserting into a new table from a joint statement
  • How to do sql pivot with multiple values in single column
  • Multiple rows into columns with column values group by columns in SQL Server
  • Data of previous quarters based on sysdate
  • ORA-00942: table or view does not exist .or We are not able to drop
  • SQL Where date1 is 3 days bigger than date2
  • #1235 - This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' in MySQL
  • Can I SELECT *, COUNT(*) in the same query?
  • PLS-00642: local collection types not allowed in SQL statements. i am using oracle datadase 12c
  • How can I convert an integer representing EPOCH time to a timestamp in Athena (Presto)?
  • Find the One Random Set_id from each unique Skill_id
  • SQL ORACLE ORA-00923: FROM keyword not found where expected
  • implement a manual increment with just simple SQL
  • SYSDATETIMEOFFSET() to turn off the offset
  • If I query from V$SQL view, does it include SQL that are still running and not yet finished?
  • Is there a way to join results from two queries in Python using sqlalchemy engine?
  • What is the query to choose the number of people living at each address?
  • Filter By date with format 'dd/mm'
  • Listagg in query having aliases
  • SQL stored procedure error about int while there is no int
  • Selecting columns from string
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk