| Author |
Topic |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2011-02-01 : 10:59:23
|
| I want to write a select statement that returns all records with the current date. The date field is int 20110131.I've triedSelect *from oeordhdrwhere month(getdate()) = substring(entered_dt,5,2) and day(getdate() = substring(entered_dt,7,2) and year(getdate()) = left(entered_dt,4)Doesn't seem to like the substring function. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-02-01 : 11:25:05
|
Which SQL Server version? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2011-02-01 : 11:27:12
|
| SQL 2000 |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-02-01 : 11:35:36
|
Select *from oeordhdrwhere convert(varchar(8),entered_dt) = dateadd(day,(datediff(day,0,getdate())),0) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-02-02 : 09:06:23
|
| Select *from oeordhdrwhere entered_dt=CONVERT(char(8),getdate(),112)*1MadhivananFailing to plan is Planning to fail |
 |
|
|
chapm4
Yak Posting Veteran
58 Posts |
Posted - 2011-09-26 : 13:30:47
|
| Is there a difference if I am using datetime instead of int and using sql server 2005 instead of 2000? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2011-09-26 : 14:11:10
|
hey visakh - it is ok if you like to answer this  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
|
|
chapm4
Yak Posting Veteran
58 Posts |
Posted - 2011-09-26 : 15:34:53
|
| Thanks |
 |
|
|
|