|
-
Oct 22nd, 2007, 04:58 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] How to Convert String 111007 to date 11/oct/07 ?
Hi All,
Anyone here please help me convery string value 111007 to date Data Type :11/oct/07
Thanks in Advance
NuFLaVoRs
Last edited by nUflAvOrS; Oct 22nd, 2007 at 05:30 AM.
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Oct 22nd, 2007, 05:20 AM
#2
Thread Starter
Hyperactive Member
Re: How to Convert String 111007 to date 11/oct/07 ?
I was solved the problem
This is my Solution, does anyone got better solution ?
Please post to let me know.
Thanks ya
vb Code:
Dim CdateVal As Date
Dim StrVal As String
StrVal = "111007"
CdateVal = DateSerial(Mid(StrVal, 5, 2), Mid(StrVal, 3, 2), Mid(StrVal, 1, 2))
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Oct 22nd, 2007, 05:22 AM
#3
Re: How to Convert String 111007 to date 11/oct/07 ?
 Originally Posted by nUflAvOrS
Hi All,
Anyone here please help me convery string value 111007 to date Data Type :11/oct/07
Thanks in Advance
NuFLaVoRs 
Code:
Dim dm As String, dt As Date
dm = "111007"
dt = Left(dm, 2) & "-" & Mid(dm, 3, 2) & "-" & Mid(dm, 5)
dt = Format("11-10-07", "dd/mmm/yyyy")
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
-
Oct 22nd, 2007, 05:24 AM
#4
Thread Starter
Hyperactive Member
Re: [RESOLVED]How to Convert String 111007 to date 11/oct/07 ?
Thanks your solution,
I appreciated your help ^^
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Oct 22nd, 2007, 05:24 AM
#5
Re: [RESOLVED]How to Convert String 111007 to date 11/oct/07 ?
if your date doesn't have to be a date variable, you could use the format$ command
newstring$ = format$(olddate, "dd/mmm/yy")
i am currently reinstalling OS and i don't have vb installed right now so i can't remember for sure if it has to be converted to a long first.
-
Oct 22nd, 2007, 05:29 AM
#6
Thread Starter
Hyperactive Member
Re: [RESOLVED]How to Convert String 111007 to date 11/oct/07 ?
Dear Sir Load Orwell ,
I had tried the solution you were provided, it return 04/Dec/03
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
-
Oct 22nd, 2007, 05:56 AM
#7
Re: How to Convert String 111007 to date 11/oct/07 ?
Anyone here please help me convery string value 111007 to date Data Type :11/oct/07
a return value from format is not a date data type, a date data type is a date value, that is displayed as the setting in system locale (or a formatted string)
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 22nd, 2007, 07:51 AM
#8
Re: How to Convert String 111007 to date 11/oct/07 ?
Your own solution is the best, as long as the string is always in this format.
Any output from the Format function is a string, and when assigned to a date variable, the output is dependent on you local settings. This is not acceptable.
-
Oct 22nd, 2007, 07:48 PM
#9
Thread Starter
Hyperactive Member
Re: How to Convert String 111007 to date 11/oct/07 ?
Thx westconn1 and Frans C.
The Theory help me a lot...
I will mark this thread resolved.
Thanks you...
Where there is no hope, there can be no endeavor.
There are two ways of rising in the world, either by your own industry or by the folly of others.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|