Solved

Type timedate is not a defined system type.

Posted on 2009-05-19
18
2,397 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
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
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
 
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In this article I will describe the Detach & Attach 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.
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

791 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