Excel formula to convert date from dddd mmmm dd, yyyy to dd/mm/yyyy - vba

I'm trying to convert a long date in excel from the format of dddd mmmm dd, yyyy to dd/mm/yyyy using a formula
Example:
Convert the following:
Tuesday August 23, 2016
To:
23/08/2016
I've tried using substitute and search without any success and as far as I am aware there is no function where I can input as one format and withdraw it as another format, I tried using =Text(A1, "dd/mm/yyyy") too but that doesn't work either.
Any ideas?

So, using #Bathsheba suggestion, I went around this the long way but it works.
Try:
=DATEVALUE(CONCATENATE(MID(A1,1+FIND(" ",A1,FIND(" ",A1)+1),2),MID(RIGHT(A1,LEN(A1)-FIND(" ",A1)),1,3),RIGHT(A1,4)))
Explaination:
MID(A1,1+FIND(" ",A1,FIND(" ",A1)+1),2)-This finds the day in dd format from the string in A1
MID(RIGHT(A1,LEN(A1)-FIND(" ",A1)),1,3)-Takes the first three letters of the month from the string in A1
RIGHT(A1,4)-Takes the year from the string in A1
It then takes these values and concatenates them into the format of dd mmm yyyy. The DATEVALUE then changes this into the correct format of dd/mm/yyyy. This works for all dates in you format.
Note: The cell, which this formula lies, should be formatted for short date.

Custom format the cells as dd/mm/yyyy and use this formula:
=DATEVALUE(RIGHT(A1,LEN(A1)-FIND(" ",A1)))
or without any additional formatting:
=TEXT(RIGHT(A1,LEN(A1)-FIND(" ",A1)),"dd/mm/yyyy")

then your dates might need a bit of cleaning :]
=Text( Mid( Trim(Clean(A1)), Find(" ", Trim(Clean(A1)) ), 99) * 1, "dd/mm/yyyy")
Update
I just noticed the vba tag
[a1].NumberFormat = "dd/mm/yyyy"
[a1] = Split([a1], , 2)(1) ' "Tuesday August 23, 2016" to "August 23, 2016"

Related

How to convert string to mm/dd/yyyy format

How do I change a string like "15:33:56 Thursday 17th, November 2016" to mm/dd/yyyy date format. I have already tried to use the inbuilt VB.NET date function CDate()
Here is some code that works for the date you gave as an example.
Dim str As String = "15:33:56 Thursday 17th, November 2016"
'Remove the "th" from "17th, since this confuses the parser
str = System.Text.RegularExpressions.Regex.Replace(str, "[a-z]{2}(?=,)", String.Empty)
'change the date to mm/dd/yyyy format
str = DateTime.Parse(str).ToString("MM/dd/yyyy")

Standard Date and Time Format Strings Missing Common Format

None of the Standard Date and Time Format Strings (e.g. "d", "D", etc.) provide the format I am looking for for a vb.net application. "D" is the closest, but I do not want to display the day of the week. I need a format that will provide a date display like this: "March 18, 2015" for culture en-US. I know I could use date.ToString("MMMM dd, yyyy"), but I want the format to change for other cultures. For example, in France I want it to display as "18 mars 2015". This should be simple, so I know I'm missing something!
Dim cj As New CultureInfo(Thread.CurrentThread.CurrentCulture.Name())
dt = #3/18/2015#
dts = dt.ToString("MMMM dd, yyyy", cj)

Convert/Update a text to another string (dates)

I need to change the format of a string which is in date format like this:
Wednesday, 10 April, 2013
into
10 April 2013
What is the best way of achiveing this?, i.e remove the day and commas
myDate.ToString("dd MMMM yyyy")
this will allow you to customize the format as much as you'd like ex.
myDate.ToString("dd-MMMM/yyyy")
there are also conversions built into .net such as
.ToShortDateString()
.ToLongDateString()
if the input is a string then you have to convert to a date , then parse back into a formatted string
Date.Parse("Wednesday, 10 April, 2013").ToString("dd-MMMM/yyyy")
If the input value is a string then you could to convert to a date and then back to your required format
Dim provider As CultureInfo = CultureInfo.InvariantCulture
Dim dateText = "Wednesday, 10 April, 2013"
Dim dt = DateTime.ParseExact(dateText, "dddd, dd MMMM, yyyy", provider)
Console.WriteLine(dt.ToString("dd MMMM yyyy"))
Try this.
Date.Today.ToLongDateString

Copying Dates from one Excel sheet to another Excel Sheet?

I am trying to copy a date from one excel sheet formated as so: "dd MONTH YYYY" (example: "19 January 2012"), this date is got using the =now() function.
I want to copy this date into a second excel sheet in a mid-sentence position as such:
"Today is 19 January 2012" I am using the following formula in the cell:
="Today is "& 'Sheet1'!c3&" the weather is fine"
However the sentence returns like this:
Today is 40927.4598005787 the weather is fine
How do I get this to show the date in the same format as sheet one?
Thanks.
You can specify a format with TEXT()
="Today is " & TEXT(sheet1!c3, "dd mmmm yyyy") &" the weather is fine"

Format function vba changing date

The format function in vba is changing the date. e.g for format("3/12/2009","DD/MM/YYYY"), the function returns 12/03/2009 where "3/12/2009" is what excel vba reads from a cell that has the value 12-Mar-2009 and the format as "dd-mmm-yyyy"
No it's not.
If a date-as-string is passed to the Format function, it will parse it using current regional settings. Your settings are obviously MM/DD/YYYY which is default for USA. Nothing prevents Excel from displaying a date as DD/MM/YYYY if set manually, but by default it would display MM/DD/YYYY.
To do: Stop reading dates as strings. Read them as dates.
dim d as date
d = activecell.value
Had few times problem myself where VBA in Access reades most dates as europian but some as USA:
This DOES NOT work properly:
myRs.FindFirst ("Date =#" & myDate & "#")
This works:
myRs.FindFirst ("Date =#" & Format(myDate, "Long Date") & "#")
The long date (eg 01 January 2012) clearly makes the difference between month and day