Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Amber_Deslaurier
Starting Member
40 Posts |
Posted - 2010-06-24 : 20:27:34
|
| Hi,I am linking Teradata to Excel dynamically and I want to know if I should CAST a date as date before I make the link... in my SQL code I will want to put a restriction so that it only extract the most latest date... what should the code look like to retrieve the data based on the latest date? example: Max(date_a) ?tyAmber |
|
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2010-06-25 : 01:28:48
|
hi,CAST is used only to convert data from one to another data type. so this won't help your query to retrieve the newest records.to extract the most latest data using date something like:select * from MyTablewhere Date > convert(varchar(10), getdate(),120) Code my differ on which datatype date is in your database, but this query should take only today's data.otherwise, describing your case is a matter of either thorough ETL process to insert all the data missing on destination and present on source and updating data present both on source and destination, but with changes on source. |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2010-06-25 : 03:10:23
|
| Your convert is also unnecessary.select * from mytable where mydate > (select max somecontroldate from somewhere)There is no need to convert formats, unless the somecontroldate is not in "date" format. Compare a date field to a date field.Comparing a date to a character format version of a date brings in locaalisation issues - i.e. USA date formats, UK Date formats, Swedish date formats etc.... |
 |
|
|
Amber_Deslaurier
Starting Member
40 Posts |
Posted - 2010-06-25 : 06:18:18
|
| Thanks I will try it out |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2010-06-25 : 10:36:57
|
quote: Originally posted by slimt_slimt hi,CAST is used only to convert data from one to another data type. so this won't help your query to retrieve the newest records.to extract the most latest data using date something like:select * from MyTablewhere Date > convert(varchar(10), getdate(),120) Code my differ on which datatype date is in your database, but this query should take only today's data.otherwise, describing your case is a matter of either thorough ETL process to insert all the data missing on destination and present on source and updating data present both on source and destination, but with changes on source.
Seems unlikely that this would be valid in Teradata SQLwhere Date > convert(varchar(10), getdate(),120) Amber_Deslaurier:This forum is for questions about Microsoft SQL Server not Teradata, so you should post your questions on a forum where they answer Teradata questions.CODO ERGO SUM |
 |
|
|
|
|
|
|
|