|
-
May 5th, 2004, 05:48 AM
#1
Thread Starter
Lively Member
Formating date/time
Hi
I can't seem to get this date/time formated, i've been mucking around with it for a while and i keep getting an error saying invalide .ToAODate format
Can anyone help? this is the text i need to format' its a string:...
200404261726
Its in: year/month/day/time I want to show it as 26/04/2004 17:26
Thanks
-
May 5th, 2004, 09:24 AM
#2
Where data is a string containing your value...
VB Code:
dim x as datetime = new datetime(data.substring(0,4), data.substring(4,2), data.substring(6, 2), data.substring(8,2), data.substring(10,2), 0)
msgbox(x.tostring("g"))
I've not tested it but see what happens.
I don't live here any more.
-
May 5th, 2004, 09:28 AM
#3
Here, I've wrapped it for you...
VB Code:
function RectifyDate(ugly as string) as string
dim x as datetime = new datetime(ugly.substring(0,4), ugly.substring(4,2), ugly.substring(6, 2), ugly.substring(8,2), ugly.substring(10,2), 0)
return x.tostring("g")
end function
Using a DateTime object will help in validating the data too. If the date is invalid then you'll get an exception 
There are other ways to do it but this is neater and safer.
I don't live here any more.
-
May 5th, 2004, 06:01 PM
#4
Thread Starter
Lively Member
Thank you wossname. I was getting tired of looking at it.
I did try using .DateTime, i forget what the error that was coming up with it.
I'll check it out and see if it works ok.
(ugly as string) lol, your right about that. I have no idea why they stored it like that.
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
|