Re: Number to Date.
From: Dylan (anonymous_at_discussions.microsoft.com)
Date: 04/07/04
- Next message: anonymous_at_discussions.microsoft.com: "Dynamic query...problem"
- Previous message: shif: "timeout"
- In reply to: Vishal Parkar: "Re: Number to Date."
- Next in thread: Vishal Parkar: "Re: Number to Date."
- Reply: Vishal Parkar: "Re: Number to Date."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 7 Apr 2004 05:00:43 -0700
Hi vishal,
declare @p_custom_date is supposed to be a prompt for
users to enter a date. Is this how you pull this off in
SQL? When I run it in Query Analyzer it doesn't prompt
me and so it returns no rows. I manually enter a date in
the place of @p_custom_date for the datediff clause it
seems to work.
Any ideads?
Thanks,
Dylan
>-----Original Message-----
>Try following:
>
>declare @p_custom_date datetime
>
>select *
>from (select accnt_code
>, convert(char(8),due_date) due_date, amount
>from salfldgtel
>WHERE ( ( ( ACCNT_CODE LIKE '51%')
>AND ( ( ALLOCATION <> 'A' ) ) ) )
>AND accnt_code <> '511534'
>AND accnt_code <> '512088'
>AND accnt_code <> '512165'
>AND accnt_code <> '515124'
>AND accnt_code <> '512199'
>AND accnt_code <> '518020'
>AND accnt_code <> '511538'
>--if due_Date is integer
>AND convert(datetime, cast(due_date as char(8)))
between '19000101' and '20050101'
>--and trunc(mod(due_date,1E4)*1E-2) between 1 and 12 CAN
BE CHANGED TO
>and round(((due_date % 10000) * .01),0,1) between 1 and
12
>-- and mod(due_date,1E2) between 1 and 31)x CAN BE
CHANGED TO
>and (due_date % 100 ) between 1 and 31)x
>--to_date(&p_custom_date,'DDMMYYYY') - x.due_date > 60
>--above clause can be changed as follows, assuming you
are looking for difference in two dates
>in terms of number of days.
>where datediff(dd,@p_custom_date , x.due_date) > 60
>order by accnt_code
>
>
>dylan,
>as you must have realized that,you can not straight away
put the query that is working in
>oracle into sql server. simply because the functions
like trunc/mod and other expressions like
>1E4/1E2 can not be accepted by sql server as it is. I've
tried giving you closest possible
>answer. Try referring to following url which will be
more helpful to you.
>
>Migrating Oracle Databases to SQL Server 2000
>
>http://microsoft.com/sql/techinfo/deployment/2000/Migrate
Oracle.asp
>
>
>--
>Vishal Parkar
>vgparkar@yahoo.co.in
>
>
>
>.
>
- Next message: anonymous_at_discussions.microsoft.com: "Dynamic query...problem"
- Previous message: shif: "timeout"
- In reply to: Vishal Parkar: "Re: Number to Date."
- Next in thread: Vishal Parkar: "Re: Number to Date."
- Reply: Vishal Parkar: "Re: Number to Date."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
- Re: Accidental delete in linked table
... the prompt essentially askes for CommitTrans or Rollback. ... What are you running
such queries against the production database ... table in SQL Server contained over
12,000,000 records. ... SQL Server, I panicked and tried to stop the query. ...
(comp.databases.ms-access) - Re: help with Where clause
... If you get a prompt for tblOrders.RemainingQuantity, ... I notice that your
query is returning three columns, ... Dirk Goldgar, MS Access MVP ... I have
2 list boxes with the same SQL, 1 set to display the OrderID ... (microsoft.public.access.formscoding) - Re: Client Enterprise manager security
... To configure it from client side, you can check the box of " Always prompt ...
SQL authentication: ... This check box specify that SQL Server must always prompt
for the login ... (microsoft.public.sqlserver.security) - Re: Use of SP?
... SQL> create table customer( ... SQL> create table pricelist( ...
Load price table with data -- ... SQL> accept bval prompt 'Enter value for isreseller:
... (comp.databases.oracle.server) - Re: software report showing software in add remove programs on all ser
... If you clone this report: ... There are two prompts, remove the prompt
for Software Title. ... revise the SQL ... I need to get a report which shows
all the software installed on all our ... (microsoft.public.sms.inventory)