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 |
|
Maachie
Yak Posting Veteran
69 Posts |
Posted - 2008-11-18 : 11:49:19
|
| column is CHDEFAULTLOGIN with datatype nvarcharSELECT TOP (100) PERCENT ITOKENNUM, BENABLED, CHSERIALNUM, DATEPIN, DATEENABLED, DATETOKENASSIGNMENT, DATELASTLOGIN, IUSERNUM, CHLASTNAME, CHFIRSTNAME, CHDEFAULTLOGIN, CHKEY, CHDATA, iReplacingTokenNum, iTypeFROM dbo.ACE_USERSWHERE (CHDATA <> '') AND (CHSERIALNUM = '') AND (CHDEFAULTLOGIN LIKE 'zz%')and (CHDEFAULTLOGIN like 'zzz%') and (CHDEFAULTLOGIN like 'zzz%') and (DateDiff(d,Cast((substring(CHDEFAULTLOGIN , 4, 2) + '/' + substring(CHDEFAULTLOGIN , 6, 2) + '/' + substring(CHDEFAULTLOGIN , 8, 2)) as datetime), Getdate()) >= 30)ORDER BY CHDEFAULTLOGIN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-18 : 11:51:39
|
| how will values of CHDEFAULTLOGIN be? |
 |
|
|
Maachie
Yak Posting Veteran
69 Posts |
Posted - 2008-11-18 : 12:20:13
|
| Thank you for the response. here this is how the data is.ZZzz01042008CHENZ3zz01102008honorszz01312008COLAKKzz02072008INTSHEWAzz030308GALLISzz041007DISCOGzz043008mattet1zz050707EDENGzz070708MAKEEIzz081707TCSBALAMzz090706STEELGzz122006WALKEL1zzz002222008WUY6zzz01/02/2008TURNEAzzz01/08/2008wachsvzzz01/21/2008PARADNzzz01/24/2008modreesjzzz01/29/2008SPRAFRzzz010108barbegzzz010108BORASzzz010108BOSUKAzzz010108CammaLzzz010108chengjzzz010108CONDUMzzz010108FISCHTzzz010108HARIHCzzzzALMEIA2-28-bulkzzzzanjan1-18-07-bulkzzzzatiass1-18-07-bulkzzzzAXTELH2-28-bulkzzzzBALLM112-18-06-Bulkzzzzbarren2-28-bulkzzzzBAUGHM12-28-bulkzzzzBEBIEG2-28-bulkzzzzBELLT2-28-bulkzzzzBENGALLJ12-18-06-BulkzzzzBENMOYLD12-18-06-Bulkzzzzwrongly craeted |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-18 : 12:29:05
|
| you need to first extract only date values and then apply datediff on them. else it will break. |
 |
|
|
Maachie
Yak Posting Veteran
69 Posts |
Posted - 2008-11-18 : 12:48:39
|
| How would I do that? Any suggestion with the data being like this? |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-11-18 : 13:31:22
|
quote: Originally posted by Maachie How would I do that? Any suggestion with the data being like this?
try using ISDATE() function. |
 |
|
|
Maachie
Yak Posting Veteran
69 Posts |
Posted - 2008-11-18 : 14:13:31
|
| show me an example to do this. I am new to sql. Thanks. |
 |
|
|
|
|
|
|
|