Solved

Type timedate is not a defined system type.

Posted on 2009-05-19
18
2,354 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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

705 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

11 Experts available now in Live!

Get 1:1 Help Now