I want to do something relatively straightforward please help I'm stuck
Given today's date is 02 May, 2021 in my current timezone (Pacific Standard Time), build the string 20210502 (yyyymmdd format) dynamically.
What is the simplest way to do this in ADF? I tried following but returns error invalid expression:
#substring(formatString(getutcdate()),0,8)
I'm also not sure how to make it flexible so I can enter a different timezone if I want like Pacific Standard Time.
You can create a timezone variable and pass that value to convertFromUtc or convertTimeZone function. And you can choose format as you need. Here is the format specifiers list.
You can follow this:
expression:#replace(split(convertFromUtc(utcnow(),variables('timezone'),'u'),' ')[0],'-','')
Output:
I have following string:
CO_CAS_REA_NO_VIPPLUS_20190402_BONUS
I would like to Extract the Date part (20190402) and convert it into DD/MM/YY format if possible.
I have tried some 'Search' and 'extraction' formulas but to no avail.
does anyone have any ideas how to do this in excel or VBA?
Other variations of the data string would be like:
COCASREAHVPLUSVIPUK20190827CRMFSDEP
COCASREALVWINFIDEGL20190809CRMPTS
COSBINFLVFIDE20190830CRMBET
CO_CAS_RET_HVMV_UK_20190830_RB
COSB_REA_181INF_HVMV_FIDE_20190809_CRM_RB
COSBREAHVMVGL20190831CRMFBFSQUAL
COSBINFLVNO20190816CRMFB
Suppose in each string you only have one 8-digit numerical string representing the date in the form of YYYYMMDD that you want to extract, you can use one of the following three formulas to return the date:
Method 1:
=DATE(LEFT(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),4),MID(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),5,2),RIGHT(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),2))
Method 2:
=DATEVALUE(LEFT(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),4)&"/"&MID(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),5,2)&"/"&RIGHT(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),2))
Method 3:
=DATEVALUE(TEXT(MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)),"0000-00-00"))
Please note, all methods are using array formula so you MUST press Ctrl+Shift+Enter upon finishing the formula in the formula bar otherwise they will not function correctly. Then you can simply drag the formula down to apply across.
The logic is to use this array formula =MAX(IFERROR(--MID(A1,ROW($A$1:INDEX($A:$A,LEN(A1))),8),0)) to extract the numerical string first. Method 1 & 2 follow the same logic which is to extract the year YYYY, month MM and day DD component from the numerical string and then use use DATE or DATEVALUE function to return the date. Method 3 is using a formatting trick to quickly turn the numerical value into a text date and then use DATEVALUE function to convert the text date into a "real" date.
Let me know if you have any questions. Cheers :)
Assume your data put in Column A
In B2, enter formula :
=0+TEXT(AGGREGATE(14,6,--MID(A1,ROW($1:$250),8),1),"0000-00-00")
Then, B2 >> Format Cell, in the Number tab, choose: "Date" >> select dd/mm/yy
All copied down
with excel-formula, make use of MID() function
=MID("CO_CAS_REA_NO_VIPPLUS_20190402_BONUS",23, 8)
with VBA, you can split it with "_"
dte_str = Split("CO_CAS_REA_NO_VIPPLUS_20190402_BONUS", "_")(5)
You might find this more flexible if the text to the left changes:
Just to save you typing here is the formula in cell C1:
=MID(A1,FIND("LUS_",A1,1)+4,FIND("_BON",A1,1)-FIND("LUS_",A1,1)-4)
It does however assume that the 4 characters either side of the date are always the same.
Assuming the strings are in Column A and you're only looking for the year 2019 you could use this
=DATE(LEFT(MID(A1,SEARCH(2019,A1),8),4), MID(MID(A1,SEARCH(2019,A1),8),5,2), RIGHT(MID(A1,SEARCH(2019,A1),8),2))
I have default parameter and this parameter shows me 7 days ago with the expression below:
=DateAdd("d",-7,CDate(Format(Today(), "MM/dd/yyyy")))
But my report just running without error while the customer using "MM/dd/yyyy" time format.
Is there a way to use this parameter ALSO with "dd/MM/yyyy" format?
I would like to set a parameter to show 7 days ago but ı would like to use this parameter with both time format.
Thanks
Don't use the Format. Just put =DateAdd("d",-7,Today()). It will automatically take the Format according to System's format.
Firstly, the format part of your expression is redundant and misleading - don't use it
=DateAdd("d",-7,Today())
Secondly, you don't have any choice of how SSRS displays it's datepickers. It shows american format only (M/d/Y)
A date is a value and values do not have a format. A date is displayed and has to be entered in a format that depends on the language settings of your browser. Using a date picker, you even don't have to care about the input format. So, just use an expression that calculates the desired value:
=Today.AddDays(-7)
I have placed the below formula in a cell which returns the date value -
"02/05/2015". 'Exception Report Register' is the name of the worksheet the formula pulls from and Q:Q the range.
=(VLOOKUP(9.99999999999999E+307,'Exception Report Register'!Q:Q,1))
I have then formatted the cell so the date will convert to "Saturday, 2 May 2015"
I want to add a full stop to the end to make it "Saturday, 2 May 2015."
I have tried:
=(VLOOKUP(9.99999999999999E+307,'Exception Report Register'!Q:Q,1))&"." which returns "42126." (as expected)
I have come across the below formula but not sure how to incorporate it
=TEXT(AJ24,"DD/MM/YYYY")&" "&"is Today"
Please help!
Cheers Mallory
Just want to clarify, this question is about formatting dates with the TEXT function in MS Excel.
If your date is in cell A1, try:
=TEXT(A1,"dddd, d mmm yyyy")&"."
You can substitute 'A1' with your (bizarre) vlookup function.
For more info on date formatting with the TEXT function, see the Guidelines for date and time formats section on MS Office Support website
Using Crystal Reports 2008, I need to extract a date from a text field. This date is usually in the format dd/mm/yy, but could also be entered as d/m/yy, dd/m/yyyy, etc.
This date could appear anywhere within the string.
At the moment I am relying on the fact that the date is placed at the end of the string, without a following fullstop, and using LEFT/RIGHT to extract each date part. These parts are then passed to another formula to create a full date:
Dim AllocationDate() as Date
If Not(IsNull({Command.Notes})) then
Formula = DateValue ((ToNumber ({#Year})), (ToNumber ({#Month})), (ToNumber ({#Day})))
However, if anyone uses a variation of format, adds a fullstop or more notes after the date the whole report keels over.
Is there any way I could extract this date by looking for a pattern? I'm guessing I could the use TRIM to get around the inconsistencies in format.
tyvmia
You may want to consider using a regular expression.
Crystal Reports doesn't have native support for regular expressions, so you'll need to add a UFL: crystal reports : is there a way to regex in crystal reports?
You should be able to adapt the pattern in this question for your needs: Javascript date regex DD/MM/YYYY
Finally, you can test the pattern on your text using regexpal.com.
** edit **
Create a SQL-expression field (Oracle 10 syntax) to extract date string and convert it to a date field:
// {%Allocation Date}
(
-- match date-like string, then convert to date type; is no dates are found, NULL is returned
TO_DATE( REGEXP_SUBSTR( TABLE.FIELD, '\d{1,2}\/\d{1,2}\/\d{2,4}',1 ,1), 'dd/mm/yyyy')
)
While you could
And, as a last resort, you can try converting the multi-line string into a long string by replacing the special characters that represent CR, LF, etc. Replacing them with spaces or another innocuous character, and then treat the resultant string as if it were just a regular string (with the date in the middle).
You would still have to make some assumptions to make this possible: ONE date per string, all special characters are known (or you have to test for all possible special characters), the date has SOME conformity to the format, etc.