Solved

Type timedate is not a defined system type.

Posted on 2009-05-19
18
2,361 Views
Last Modified: 2012-05-07
Getting error...

Type timedate is not a defined system type.

can anyone help?

thanks
SELECT * FROM orders 

WHERE timedate  >= dateadd(day, 1-datepart(day, getdate()),  convert(timedate, convert(varchar(10), getdate(), 120), 120)  )

AND timedate  < dateadd(month, 1, dateadd(day, 1-datepart(day, getdate()),  convert(timedate, convert(varchar(10), getdate(), 120), 120)  ))

AND status = 'transaction authorised'

Open in new window

0
Comment
Question by:pigmentarts
  • 7
  • 4
  • 3
  • +1
18 Comments
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24421492
do you have "TimeDate" field in Orders table? it seems you don't have that field
0
 
LVL 31

Accepted Solution

by:
RiteshShah earned 250 total points
ID: 24421500
have a look at this.



SELECT * FROM orders
WHERE timedate  >= dateadd(day, 1-datepart(day, getdate()),  convert(datetime, convert(varchar(10), getdate(), 120), 120)  )
AND timedate  < dateadd(month, 1, dateadd(day, 1-datepart(day, getdate()),  convert(datetime, convert(varchar(10), getdate(), 120), 120)  ))
AND status = 'transaction authorised'
0
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 24421512
SELECT * FROM orders
WHERE timedate  >= dateadd(day, 1-datepart(day, getdate()),  convert(timedate, convert(varchar(10), getdate(), 120), 120)  )
AND timedate  < dateadd(month, 1, dateadd(day, 1-datepart(day, getdate()),  convert(datetime, convert(varchar(10), getdate(), 120), 120)  ))
AND status = 'transaction authorised'

0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 24421695
In sql 2005 the data type is datetime, in sql 2008 you have date, time, datetime, datetime2 etc...

Based on the code you have, it looks like the convert should be converting to datetime not timedate.


SELECT * FROM orders
WHERE timedate >= dateadd(day, 1-datepart(day, getdate()), convert(DATETIME, convert(varchar(10), getdate(), 120), 120) )
AND timedate < dateadd(month, 1, dateadd(day, 1-datepart(day, getdate()), convert(DATETIME, convert(varchar(10), getdate(), 120), 120) ))
AND status = 'transaction authorised'
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24421712
Mark is absolutely right, that is what I have given in my query above.
0
 
LVL 51

Assisted Solution

by:Mark Wills
Mark Wills earned 250 total points
ID: 24421776
Right, see that now...

so what about :

SELECT * FROM ORDERS
WHERE timedate  BETWEEN DATEADD(month, DATEDIFF(month, 0, getdate()),0) and DATEADD(ss,-1,DATEADD(month, DATEDIFF(month, -1, getdate()), -1) + 1)


Does that make it a bit more different ? Certainly a lot faster :)
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24421790
Good Work mark, I was about to do the same, you beat me in this for sure :D

0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
LVL 31

Expert Comment

by:RiteshShah
ID: 24421888
I wonder, query given in post # 24421512. is it working? my query should work for sure given in second post of this question, before everybody. I was atleast expect assisted in this case.
0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 24421916
@pigmentarts,

I think there has been a small injustice here. RiteshShah did in fact get the SQL Query correctly coded with both instances of DateTime.

0
 
LVL 12

Author Comment

by:pigmentarts
ID: 24439361
what did i do?  this is what i was thinking..... if i did not split like this then sorry


RiteshShah did a wonderful job at answering my question  however the post 24421776 by Mark also worked and my query did indeed load faster.

I know that RiteshShah answered my question but I felt that both RiteshShah and Mark wills helped me in understanding and Marks query helped me to see the error of my mistake.
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24439416
:) yes mark, no question in split
0
 
LVL 12

Author Comment

by:pigmentarts
ID: 24439493
o I see what i did did now! again thanks for you help.
0
 
LVL 12

Author Closing Comment

by:pigmentarts
ID: 31582973
Thank you for you help.
0
 
LVL 31

Expert Comment

by:RiteshShah
ID: 24439503
thanks pigmentarts and Mark
0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 24439556
Happy to help :)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now