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 |
|
batcater98
Starting Member
22 Posts |
Posted - 2009-07-29 : 10:30:28
|
| I have a need to do a where condition using the LIKE clause. I need to build a dynamic string based on yesterdays date. I have done this in Teradata - but can not figure out how to do it in SQL.Here is my Teradata Statement:LIKE '%'||(SUBSTR(DATE-1(FORMAT 'YYYY-MM-DD'),6,2) ||'_'|| SUBSTR(DATE-1(FORMAT 'YYYY-MM-DD'),9,2) ||'_'|| SUBSTR(DATE-1(FORMAT 'YYYY-MM-DD'),3,2)) ||'%'This give me a format of MM_DD_YY for yesterdays date. Can someone give me the syntax for doing the same thing in MS SQL?Thanks,Ad.Regards,The Dark Knight-Give What is Right, Not What is Left- |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-07-29 : 10:45:02
|
| select '%' + replace(convert(varchar(10),dateadd(day,-1,getdate()),1),'/','_') + '%' |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-07-29 : 12:29:02
|
SELECT CONVERT(CHAR(10), DATEADD(DAY, DATEDIFF(DAY, 1, GETDATE()), 0), 120) N 56°04'39.26"E 12°55'05.63" |
 |
|
|
|
|
|
|
|