| Author |
Topic  |
|
|
sri99860
Starting Member
7 Posts |
Posted - 12/11/2012 : 09:02:57
|
Hello,
I am new to SQL Server 2008. Need replacement functions for the below queries(sql)in sql server 2008.
1. trunc(sysdate)-1.0001 2. Trunc(sysdate - 3) 3. Trunc(sysdate, 'MM') 4. trunc(sysdate, 'DAY') 5. TO_YMINTERVAL('03-00') 6. TO_YMINTERVAL('00-01'))) +.99999 7. Trunc(last_day(Trunc(sysdate, 'MM') 8. to_char(Trunc(sysdate-1), 'D') 9. next_day(trunc(sysdate)-7.00001,'Saturday') 10.trunc(last_day(Trunc(sysdate, 'MM') 11.add_months(trunc(sysdate,'Q'),- 3)
Appreciate for your quick response.
Regards, Sri.
|
|
|
sodeep
Flowing Fount of Yak Knowledge
USA
7173 Posts |
|
|
sri99860
Starting Member
7 Posts |
Posted - 12/12/2012 : 05:33:13
|
Thanks for your reply.
The link was provided had only trunc replacement functions.
Any one knows other functions.
Regards, Sri. |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1420 Posts |
|
|
sri99860
Starting Member
7 Posts |
Posted - 12/13/2012 : 04:38:08
|
Thanks Bandi.
I am getting "Operand data type date is invalid for subtract operator." error if i subtract one query from the other. However if the query was running successfully if i split the query.
Select 'Previous 36 Months' as DateRange, CONVERT(DATE,DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0)),120) - CONVERT(VARCHAR(10),DATEADD(m,-1+.99999,GETDATE()),120) as EndDate
Regards, Sri. |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1420 Posts |
Posted - 12/13/2012 : 04:47:49
|
In mssql, You can't subract two dates. refer DATEDIFF(),DATEADD() date functions...
-- Chandu |
Edited by - bandi on 12/13/2012 04:48:47 |
 |
|
| |
Topic  |
|
|
|