date fields that are not date types

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hey all,

i have a number field i need to convert
from
20050818
to
08182005

can someone please show me some ways i can do this?

thanks,
rodchar
 
rodchar said:
i have a number field i need to convert
from
20050818
to
08182005

Without resorting to nasty Modular mathematics :

i = 20050818

s = i.ToString()
s = s.SubString( 4, 4 ) & s.SubString( 0, 4 )

i = CInt( s ) ' or Convert.ToInt32( s ), whichever you prefer.

Neither of which, of course, are dates - to get those, you'd need :

s = i.ToString()
s = s.SubString( 0, 4 ) _
& "-" & s.SubString( 4, 2 ) _
& "-" & s.SubString( 6, 2 )
d = CDate( s )

HTH,
Phill W.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top