Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Convert string to date

Posted on 2016-11-07
3
Medium Priority
?
90 Views
Last Modified: 2016-11-09
Hi,

in vb.net, I have a column with some dates in string format, they are in french and they only have the month and the day, such as "12 octobre", is there a way that I can convert these strings into date format?

Thank you
0
Comment
Question by:FCapo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 27

Expert Comment

by:Shaun Kline
ID: 41877781
The TryParseExact method of the Date object may be what you are looking for. Here is the link to Microsoft's description of this function: https://msdn.microsoft.com/en-us/library/ms131044(v=vs.110).aspx
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 41878072
not sure that the month name in French will parse correctly. I would create a method that would take the word right of the space and build "select case" to find out the month.

Then you take what is left of the space and that becomes your day.

Now it you want to build a date from it, you will need a year. What will you put?
0
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 total points
ID: 41879106
Actually it should, you have to ensure that you pass the specific culture information.

Proof of concept -
Imports System.Globalization

Module Module1
	Sub Main()
		Dim fr_Date_Field = "12 octobre"
		Dim converted As Date
		If Date.TryParseExact(fr_Date_Field, "dd MMMM", New CultureInfo("fr-FR"), Globalization.DateTimeStyles.None, converted) Then
			Console.WriteLine("Successfully converted {0} to {1}", fr_Date_Field, converted.ToString("MM/dd"))
		Else
			Console.WriteLine("Failed to convert {0}", fr_Date_Field)
		End If
		Console.ReadLine()
	End Sub
End Module

Open in new window

Produces the following output -Capture.JPG
-saige-
1

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question