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"
Related
I have a view with a date column with this format : YYYY-MM-DD and I am using that column in a SSRS report but the final user wants to have something like this:
December 31, 2018
I am using this expression:
=FormatDateTime(Parameters!prmReportDate.Value,DateFormat.LongDate)
But I am getting this:
Monday December 31, 2018
I don't need the day. Is there a way to remove it?
You could simply format the textbox as a date and specify the correct format. You'll just need to set the expression in the textbox as:
=Parameters!prmReportDate.Value
And you should be able to set the Number format property as:
And this should give you the output you expect. If it doesn't work as expected(which actually seems to be the case as I test it), should be able to apply the following expression:
=Format(Parameters!prmReportDate.Value, "MMMM dd, yyyy")
Just remove one of the ds from the expression to remove a leading zero on single digit dates.
Try something like this:
=MonthName(Month(Parameters!prmReportDate.Value),false)
& " " &
day(Parameters!prmReportDate.Value)
& "," &
year(Parameters!prmReportDate.Value)
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"
I'm using Excel VBA and want to verify 2 dates are the same. On my macro, the user enters a date in the mm/dd/yy format (01/31/15). When the macro runs, it opens a file submitted by a user in Europe. On that sheet, there is a date field where the date is entered in the dd/mm/yy format (31/01/15). I'm wondering if there is an easy way to compare these 2 dates to verify that they are the same.
I could convert one of the dates into the other format and then convert both to a date serical to see if they are the same. I wanted to check and see if there was an easier way or a function that could do that.
Thanks for the help........
So apparently the MSDN Library has a converter Sub:
Function MakeUSDate(DateIn As Variant) As String
' Do nothing if the value is not a date.
If Not IsDate(DateIn) Then Exit Function
' Convert the date to a U.S. Date format.
MakeUSDate = "#" & Month(DateIn) & "/" & Day(DateIn) & "/" & Year(DateIn) & "#"
End Function
I am trying to convert a User Response from a report's prompt into a date. The ToDate() and FormatDate() functions work correctly, but only return the month of January.
I created a detail object called [xUser Response] whose formula is:
=UserResponse([Hours]; "As of Period YYYYMM"),
where [Hours] is the data source and "As of Period YYYYMM" is the prompt string.
Then, I used this detail object in another formula:
="Data as of "+ FormatDate(LastDayOfMonth(ToDate([xUser Response]; "yyyymm")); "Mmmm dd, yyyy")
The formatting applied through the other functions is all correct, but the date only gives me January, no matter what month I submit in the query prompt. If you know how to get around this, please let me know.
Thanks.
You should use yyyyMM as a format mask to convert your string to a date. mm is used to denote minutes.
Thus, your formula would be ="Data as of "+ FormatDate(LastDayOfMonth(ToDate([xUser Response]; "yyyyMM")); "Mmmm dd, yyyy")
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