Connecting Tech Pros Worldwide Forums | Help | Site Map

covert a number in to Date format YYYYMMDD

Newbie
 
Join Date: Oct 2009
Location: cjennai
Posts: 4
#1: 4 Weeks Ago
I have one number i want to convert in to a date format

the size of the value is =8 Char
20091212
i ant to conver it in to a date format
my sysyem doent understand wether its adate or not its taking as a number

Thanks
Nani

Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#2: 4 Weeks Ago

re: covert a number in to Date format YYYYMMDD


Quote:

Originally Posted by naaniibabu View Post

I have one number i want to convert in to a date format

the size of the value is =8 Char
20091212
i ant to conver it in to a date format
my sysyem doent understand wether its adate or not its taking as a number

Thanks
Nani

Hi
assuming that it is always an 8 digit number as yyyymmdd then something like

Expand|Select|Wrap|Line Numbers
  1. Dim intDateNumber as long
  2. Dim strDateNumber as string
  3. Dim Thisdate as Date
  4.  
  5. intDateNumber = 20091212
  6. strDateNumber = CStr(intDateNumber)
  7.  
  8. ThisDate = DateSerial(left(strDate,4),Mid(strDateNumber,5,2),right(strstrDate,2))
In VBA or VB6 you don't need to convert to a string, but not sure in .NET (I assume you will need to!).


MTB
Newbie
 
Join Date: Oct 2009
Location: cjennai
Posts: 4
#3: 4 Weeks Ago

re: covert a number in to Date format YYYYMMDD


Thanks MTB

todya i tried it in my machine it is not working
pls let me know what happend

Thanks
Nani
Expert
 
Join Date: Jun 2007
Location: Derbyshire, UK
Posts: 347
#4: 4 Weeks Ago

re: covert a number in to Date format YYYYMMDD


Quote:

Originally Posted by naaniibabu View Post

Thanks MTB

todya i tried it in my machine it is not working
pls let me know what happend

Thanks
Nani

Hi

I have lost my crystal ball, so maybe you could let US know what happened !!?

MTB
Newbie
 
Join Date: Oct 2009
Location: cjennai
Posts: 4
#5: 4 Weeks Ago

re: covert a number in to Date format YYYYMMDD


Hi ,

It's Working Fine thanks alot ,for your guidance

Thanks
Nani
Reply


Similar Visual Basic 4 / 5 / 6 bytes