InfoPath 2010 changing Date/Time/second Formula - infopath2010

I have this formula in a textbox to generate the date, time, and seconds. I want to format the date to mm/dd/yyyy instead of yyyy/mm/dd
translate(now(), "_-:T", "")

Use functions concat, substring, translate
concat(substring(translate(now(), "_-:T", ""), 5, 2), "/", substring(translate(now(), "_-:T", ""), 7, 2), "/", substring(translate(now(), "_-:T", ""), 1, 4))
OUTPUT:
09/12/2014

Related

How to convert date to dd/mm/yy in Excel

I am working with Amazon vendor central and downloading order data in csv format.
The date formats are as follows;
Jan 3, 2022 8:00:00 PM GMT
Please can anyone help me with a formula to convert to dd/mm/yy format?
Thanks
Laura
You can use MID() and FIND() to pull out the data to enter into a DATE(year, month, day) or DATEVALUE() formula then use TEXT(date, "DD/MM/YY") to format it.
The DATEVALUE Function can parse text as a date; but it seems it needs to be formatted "3 Jan 2022" as opposed to "Jan 3, 2022"
I have used an array rather than MID() to pull out the details and the formula for that is:
=LET(date, E3,
values, FILTERXML("<t><s>"&SUBSTITUTE(date, " ","</s><s>")&"</s></t>","//s"),
TEXT(DATEVALUE(SUBSTITUTE(INDEX(values, 2), ",", " ") & INDEX(values, 1) & " " & INDEX(values, 3)), "DD/MM/YY")
)

VBA: AddDate + time changes the format

Can someone advise, please?
I have used DateSerial, DateValue with mixed results, also Format(... doesn't work in this case.
When I use DateAdd("d", 1, DateValue(x.Value))
06/05/2021 20:20:20
is changed to
05/07/2021 20:20:20
All I need is this 06/05/2021 20:20:20 to be changed to this 07/05/2021 20:20:20
FYI if it helps the format of my cells is as follows:
Try this and swap dd/mm to mm/dd (the format will remain dd/mm/yyyy):
Format(DateAdd("d", 1, cel.Value), "mm/dd/yyyy") & " 18:59:59"
If you wish to use DateAdd, and your value is a true date value (not text), use:
DateAdd("d", 1, x.Value)
This will not alter a time part. If x is 2021-05-06 20:20:20, result will be:
`2021-05-07 20:20:20`
If x is 2021-05-06 18:59:59 you can add one hour:
DateAdd("h", 1, x.Value)
for the result: 2021-05-06 19:59:59
just x.value + 1 it'll get that it's a date and add one day

Convert the value to specific date format in Excel

I have the following date in B cell. Actually this is not in the date format.
2015-11-01-01.13.34.737000
that has to be changed into the following format:
11/01/2015 01:13:34 AM
I'm not so familiar in excel formulas. Can anyone help me to bring the expected output? Actually, I tried changing the date format using format cells but no luck and also tried some excel formulas.
-Thanks in advance
If your original value is in cell A1, then as written, this works:
= MID(A1, 6, 2 ) & "/" & MID(A1, 9, 2) & "/" & LEFT(A1, 4) & " " & SUBSTITUTE(MID(A1, 12, 8), ".", ":") & " AM"
If you need the formula to 12-hour time and append AM or PM, then obviously you need to extract that 2 digits of the input value and check whether it's >= 12, append the right string, and change the hour before you output it. By the time you've understood what the above is doing, you may begin to see how you could do that. However, since it's a bit more complex, here:
= MID(A1, 6, 2 ) & "/" & MID(A1, 9, 2) & "/" & LEFT(A1, 4) & " " & RIGHT("0" & MOD(MID(A1, 12, 2) - 1, 12) + 1, 2) & ":" & SUBSTITUTE(MID(A1, 15, 5), ".", ":") & IF(NUMBERVALUE( MID(A1, 12, 2) ) < 12, " AM", " PM")
The MOD is needed to wrap around after 12 hours, and the add/subtract 1 acrobatics are because we write hours from 1 to 12, not 0 to 11. The right("0" & foo, 2) bit simply ensures that 1-digit numbers are 0-padded to 2 digits. This seems to work, but I didn't test it totally exhaustively.
=--SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"-"," ",3),"-","/"),".",":"),":",".",3)
The above converts your original string into a string with this format:
2015/11/01 01:13:34.737000
The double unary at the beginning then converts that string to a real Excel date/time which can be formatted however you wish.

Parsing non-standard date format in Excel cell

I want to convert dates formatted like "March 30th 2017, 05:00:00.000" to an excel date value? What's the most elegant solution I can do this with using a cell-formula and not VBA?
This will do the standard "rd","th","st","nd"
=--(LEFT(A1,MIN(FIND({"rd","th","st","nd"},A1 & "thrdstnd"))-1)& ", " & SUBSTITUTE(MID(A1, MIN(FIND({"rd","th","st","nd"},A1 & "thrdstnd"))+2,LEN(A1)),",",""))
You can add other suffixes as you need to the formula
Then you can format it as you like.
Nested IFERROR functions can handle the variety of number ordinals.
=--SUBSTITUTE(REPLACE(A2, IFERROR(FIND("st ", A2),IFERROR(FIND("nd ", A2),IFERROR(FIND("rd ", A2), IFERROR(FIND("th ", A2), LEN(A2))))), 3, ", "), ", ", " ",2)
I used a custom number format of [Color10]mmmm dd, yyyy hh:mm:ss.000;;;[Color3]#. Beyond the fact that the text is left-aligned and the true dates are right-aligned, this will put text-that-look-like-dates in a red font and true dates in a green font.
If you want a true date and want to drop the time part then:
=DATEVALUE(SUBSTITUTE(LEFT(A1,FIND(",",A1)-1),"th",","))
You will need to nest SUBSTITUTE() functions to handle "nd" and "st" ordinals if you have them:
=DATEVALUE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(LEFT(A1,FIND(",",A1)-1),"th",","),"nd",","),"st",","))

Excel VBA : Convert date format from YYYY-MM-DD-HH.MM.SS.Milli to DD/MM/YYYY HH:MM:SS

I have the following datetime to convert into format DD/MM/YYYY HH:MM:SS
Cell type : General
2011-01-29-10.23.23.123100
My try:
Function:
Function ConvertDate(D1 As Date) As Long
ConvertDate = Substitute(Substitute(Substitute(D1, "/", " ", 3), ".", ":", 1), ".", ":", 1) * 1
End Function
Result:
#VALUE!
Unable to get expected result.
Use,
=--LEFT(REPLACE(SUBSTITUTE(A1, ".", ":"), 11, 1, CHAR(32)), 20)
(or the VBA equivalent). Format (or set the Range.NumberFormat property) as DD/MM/YYYY HH:MM:SS.
                  Note that A1 is left-aligned (i.e. text ) and B1 is right-aligned (i.e. true number or date )

Resources