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 |
ntn104
Posting Yak Master
175 Posts |
Posted - 2010-08-09 : 08:16:42
|
Hello,Anyone could help me to write a statement to cover the period before year 1994. The data indicated two digit year and two digit month for the fieldname "Period" (for example, 01/1994 would be 9401). I don't know how to make the statement that won't miss any months....if i stated like this PERIOD <'9400' ...will that cover all?thanks, |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-09 : 08:23:11
|
Yes, but if PERIOD is an integer datatype then it should be PERIOD < 9400 No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-08-09 : 08:23:39
|
Can you use like this ? - Instead of taking 2 digits of year take all the four digits so when century will be changed even then there will not be any chance to miss the dataDeclare @Period AS VARCHAR(7) SET @Period = '01/1994'SELECT CONVERT(INT, RIGHT(@Period, 4) + LEFT(@Period, 2) ) In your query you can use likeWHERE CONVERT(INT, RIGHT(Period, 4) + LEFT(Period, 2) ) < '199400'Vaibhav TTo walk FAST walk ALONE To walk FAR walk TOGETHER |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-09 : 08:25:40
|
PERIOD < 9400 and PERIOD > 5000Because Y2K... No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
ntn104
Posting Yak Master
175 Posts |
Posted - 2010-08-09 : 09:05:16
|
quote: Originally posted by webfred PERIOD < 9400 and PERIOD > 5000Because Y2K... No, you're never too old to Yak'n'Roll if you're too young to die.
Yes, this statement is working. Thank you! |
 |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-09 : 09:15:31
|
welcome  No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|