Solved

Type timedate is not a defined system type.

Posted on 2009-05-19
18
2,519 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

627 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