Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 28th, 2012, 02:18 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default MMddyy to yyyymmdd

Hi
is there a way to convert MMddyyyy to yyyymmdd , stored in a text file
using vb.net

Any ideas are welcome
regards
Reply With Quote
  #2 (permalink)  
Old March 29th, 2012, 03:05 AM
Authorized User
Points: 448, Level: 7
Points: 448, Level: 7 Points: 448, Level: 7 Points: 448, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 86
Thanks: 1
Thanked 12 Times in 12 Posts
Default

Hi,


just parse the string to date and use the toString with a specific DateFormat afterwards.

There are actually hundred ways to do this, in one way it could look like this:
Code:
 
         Public Function CustomConversion(dateString as String) As String
         	Dim dateFormatIn, dateFormatOut As String  
         	Dim myDate As Date

         	dateFormatIn = "MMddyyyy"
         	dateFormatOut = "yyyyMMdd" 
         	
         	myDate = Date.ParseExact(dateString, dateFormatIn, provider)
         	return myDate.ToString(dateFormatOut) 
         	
         End Function
You probably want to make it a bit safer by using TryParseExact etcetera but you get the idea..

Success !
Reply With Quote
  #3 (permalink)  
Old March 29th, 2012, 03:52 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by disel2010 View Post
Hi,


just parse the string to date and use the toString with a specific DateFormat afterwards.

There are actually hundred ways to do this, in one way it could look like this:
Code:
 
         Public Function CustomConversion(dateString as String) As String
         	Dim dateFormatIn, dateFormatOut As String  
         	Dim myDate As Date

         	dateFormatIn = "MMddyyyy"
         	dateFormatOut = "yyyyMMdd" 
         	
         	myDate = Date.ParseExact(dateString, dateFormatIn, provider)
         	return myDate.ToString(dateFormatOut) 
         	
         End Function
You probably want to make it a bit safer by using TryParseExact etcetera but you get the idea..

Success !
Hi

can you tell me how to open the file here like
Public Function CustomConversion(dateString as String) As String
Dim dateFormatIn, dateFormatOut As String
Dim myDate As Date ' where can i put the code open file C:\dates.txt

dateFormatIn = "MMddyyyy"
dateFormatOut = "yyyyMMdd"

myDate = Date.ParseExact(dateString, dateFormatIn, provider)
return myDate.ToString(dateFormatOut)

End Function
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
date format yyyymmdd belete ASP.NET 2.0 Basics 5 October 29th, 2007 08:24 AM
Validating date(yyyymmdd) with RegularExpressionVa belete ASP.NET 2.0 Basics 2 October 23rd, 2007 12:30 PM



All times are GMT -4. The time now is 06:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.