Excel 2007 Text to Date - excel-2007

I need to change this in excel from Text to Date format and I want it to change from this:
Sep 30, 1985 12:00 AM
to this:
30/09/1985
I played around but I think I'm wasting a lot of time and hopefully you can assist me please, I would really appreciate it. I tried this:
=LEFT(SUBSTITUTE(A1,",",""),12)
and I get this:
Sep 30 1985
I was trying to break it down and then in the end figure out a way of converting from text to Date but I'm getting nowhere. Please advise if there is a way.
Kind regards
D

What about that:
The thing is that it's a bit complicated. Here you get date and then you can change format.

You can use the custom format to pick the format you like
Just ensure the format is date and it works, updated the screenshot as per your request

Related

How to convert dates to valid format in Google Data Studio?

I have a google sheet with dates in europian format ( 15.09.2020 08:40 ) . When importing the sheet to data studio it detects this field as text. I try to change it to DATE but get error "Cant convert". Maybe becouse its in european format? Anyone know how to change this? I have tried formatting in google sheets with no luck...
You have to convert it yourself, with the european date as as string in the field your_field, create an additional field with following formula:
PARSE_DATETIME("%d.%m.%Y %H:%M:%S", your_field)
The details for date converting/parsing can be found here:
https://support.google.com/datastudio/answer/9739558

VBA interpretation of input date

I have this annoying date format inconsistency with Excel VBA. I have a source text file, which has dates in format of dd/mm/yyyy (i.e. the sane format). But I need to convert it to yyyy/mm/dd (for consistency, I also set up this format as default in my computer).
When I export this text file into database, if both of the dd and mm values are less than 12, VBA treats them as mm/dd/yyyy instead of dd/mm/yyyy. Even I am very confused about this non-standard date format, poor VBA.
For example, I have 06/08/2015 in text file, which is 6th August, but CDate("06/08/2015") returns 2015/06/08, i.e. 8th June. But if the text file has 15/08/2015, VBA can identify it as 2015/08/15.
How to tell VBA that 06/08/2015 is in dd/mm/yyyy format?
Any help with this annoying and tedious task would be greatly appreciated!
Use DateSerial() instead of CDate():
Dim d$
d = "06/08/2015"
MsgBox DateSerial(Right$(d, 4), Mid$(d, 4, 2), Left$(d, 2))
This way you control which bits of the date are which.

VBA equivalent to VBScript's 'SetLocale' function?

To summarize my problem, I'm currently having the exact same issue as the person from this question here. I'm trying to parse a US date into an Excel sheet that has German as default and gives me a type mismatch on most of the dates because of it.
SetLocale sounded like the perfect solution to my issue, but after a minute of further research I discovered that GetLocale and SetLocale are apparently not supported in VBA.
It sort of worked when I assigned the parsed date to a String variable (I end up with a column using either MM/DD/YYYY or DD/MMM/YYYY format depending on whether or not I had a type mismatch, as long as I use On Error Resume), but I need them in a MM/DD/YYYY date type/format in order to compare all the parsed dates to a specific date in another cell (attempting to determine if the site has had any updates since the date entered in the specific cell).
I've also tried doing TimeStamp = Format(TimeStamp, "MM/DD/YYYY") (TimeStamp being a variable containing the parsed date), but it doesn't seem to be working- most likely due to the type mismatch error.
If anyone knows a VBA equivalent of the SetLocale function used in the linked question for me to try out, I would greatly appreciate it. If there isn't any, I'll be happy to amend my question and add my current code here to try and hammer out a solution together.
Thank you for your time and your help.
If you know they are all in US format, you can use a function like this:
Function ConvertUSDate(sDate) As Date
ConvertUSDate = Evaluate("DATEVALUE(""" & sDate & """)")
End Function

VBA getdate function (?)

I wonder if there's any function in VBA which convert strings into a date?
I mean I work with dates with different formats e.g. 20150723, 07023015, 23-07-15 etc. -it's the same date for me, but VBA editor does not know it:)
What's the best way to get "real" date 2015/07/23 from string 20150723 ?
For your specific example, you can use:
cdate(format("20150723", "0000-00-00"))
which converts "20150723" into "2015-07-23" which should be recognisable to CDate as a date string.

Stop VB.net changing inputs like 01 to just 1?

i'm struggling to find a solution to this. I am currently trying to take an input like 01 and keep it that way through the program, however VB.net seems to format that down to just 1. Is there any way to stop it doing this?
Thank you in advance, i'm sorry if this is just my stupidity.
If you want to keep it as "01" , you should store it in a string format not integer or any numerical data type. If you must use integers , you can display the output only in the format you want like this :
Dim int As Integer = 1
Console.Writeline(Format(int, "00"))
This should give you the output in the desired format. I hope that was helpful for you.