Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 easy question
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

redbrad0
Advanced Member

USA
3725 Posts

Posted - 29 May 2001 :  18:31:27  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
i just can not think today and was wondering if someone could help me. i am pulling a variable out of a nvarchar field in sql. the variable comes out like 02/2003. And I am trying to seprate 02 and 2003 so i can get the month and year without the / in it. so here is the code, but for some reason the year is not working.

strDBC_B_Expiration = SQLdecode(rs("C_B_Expiration"))
strDBC_B_ExpirationMonth = left(strDBC_B_Expiration, 2)
strDBC_B_ExpirationYear = right(strDBC_B_Expiration, 4)

and here is the output..
strDBC_B_Expiration - 02/2003
strDBC_B_ExpirationMonth - 02
strDBC_B_ExpirationYear - 3

can anyone help?



Brad

BuffyNET
Junior Member

United Kingdom
126 Posts

Posted - 29 May 2001 :  18:43:05  Show Profile  Visit BuffyNET's Homepage  Send BuffyNET an ICQ Message
OK, I did this :


strDBC_B_Expiration = "02/2003"
strDBC_B_ExpirationMonth = left(strDBC_B_Expiration, 2)
strDBC_B_ExpirationYear = right(strDBC_B_Expiration, 4)
Response.Write "Month = " & strDBC_B_ExpirationMonth & " Year = " & strDBC_B_ExpirationYear


And it worked fine, so maybe it is the way you are receiving it from the database?

If it is a true date, you could extract the Year, Day and Month anyway, even the name of the Day using the VB Sunday function

Neil
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 29 May 2001 :  18:50:43  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
errrr

your right that does work. then i tried it with just replacing where it gets the data from (my database) and it returned..

12/2007
Month = 12 Year = 7

any ideas?

Brad
Go to Top of Page

BuffyNET
Junior Member

United Kingdom
126 Posts

Posted - 29 May 2001 :  18:56:17  Show Profile  Visit BuffyNET's Homepage  Send BuffyNET an ICQ Message
Maybe im being thick (it's late here!) but i have never used SQLdecode, is that a function you have written yourself?

How is the data stored in the database?

Neil
Go to Top of Page

redbrad0
Advanced Member

USA
3725 Posts

Posted - 30 May 2001 :  00:34:42  Show Profile  Visit redbrad0's Homepage  Send redbrad0 an AOL message
yes it is a function i wrote myself, but that is not the problem. the reason i say that, is because strDBC_B_Expiration is generated from the sqldecode function and comes out to the right data. just when i try to get the right 4 char's it does not work.

quote:

Maybe im being thick (it's late here!) but i have never used SQLdecode, is that a function you have written yourself?

How is the data stored in the database?

Neil



Brad
Go to Top of Page

BuffyNET
Junior Member

United Kingdom
126 Posts

Posted - 30 May 2001 :  03:02:16  Show Profile  Visit BuffyNET's Homepage  Send BuffyNET an ICQ Message
Have you tried

strDBC_B_Expiration = Cstr(SQLdecode(rs("C_B_Expiration")))


just to make sure it is a string before th emanipulation? If it doesn't work and you are completely stuck you can send me the code + fucntion etc and I will take a look


Neil
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000 Version 3.4.07