In an Access form, I need to use the date output from a date picker field to be used to search for a file in a form. However, the default data format seems to only allow slashes. Although I know the date is being stored as a number in the database.
Put simply, I need Me.myDate to output a legal file name structure, for example, yy-mm-dd. Then I can concatenate that with my file name to search for myfilename_yy-mm-dd
I always get myfilename_yy/mm/dd which is of course unusable as a file name.
Changing the format of the field obviously makes no difference to how the value is stored. What I don't understand is if the date is stored as a number, and the output is shown in the selected format, how I can override the default formatting behaviour used when I query the date.
The Format Function will allow you to format the date as you wish.
An expression to include the formatted date in a filename pattern could look like this ...
"myfilename_" & Format(Me.myDate, "yy-mm-dd") & "*"
Related
I have some dates in Text format and some other in Date format.
I tried so many things to reconvert them in proper format. DD/MM/YYYY
16/10/2022
05/12/2023
24/05/2023
I still cant figure out. They all looks in Date format but some are not. How i can re-format properly. There is sample of my dates.
https://docs.google.com/spreadsheets/d/1aNsoqXnpNkQs7LloFuHVObARqI2QEh5X8ClCu42ICyQ/edit?usp=sharing
How i can fix this?
Here's what happened :
you had a bunch of dates formatted as DD/MM/YYYY and pasted them and they were automatically parsed in the format MM/DD/YYYY leading some of them being recognized as proper dates (but not the ones you intend to have), and some of them being leaved as text.
To solve this you can copy paste the column in a text file, then import this file; when you import the data in excel, use the "text to columns" to choose the date format.
You can also change your locale date settings.
Last solution that does not involve creating a new file : copy paste your dates in a text file, add a ' in front of each line which ensures the cell content is not automatically interpreted, then parse the date from this text using the formula :
=date(right(H2,4),mid(H2,4,2),left(H2,2))
(if your text is in h2)
One last thing : some of your data in the left column is not in the correct format. You probably have a formatting problem / data quality problem in the source data you copy/pasted from.
save file in CSV or convert to csv
Open as text
Use the Text import wizard from paste
Dates comes to me as strings like that '19901226'. But my db waits for '26.12.1990'. How to change it? I know that I need regular expression but never worked with them.
I find it odd that your database expects a non ISO format date, but here goes:
echo date_create_from_format("Ymd","19901226")->format("d.m.Y");
Echos:
26.12.1990
http://sandbox.onlinephpfunctions.com/code/cd0c79eef6fb81a4e55cf314e7e8a9ff7934ada8
I have an text entry control with the input mask 00/00/0000. However it comes into the data table as just a string of numbers, e.g. 05132015. I have the datatype in the schema set to short text with a format of mm/dd/yyyy. Actually, I don't understand the difference between the format (set in the table design mode) and the input mask. Just my ignorance. I don't have a short date data type in the drop down list. In short, I want to have the user enter a short date in the format mm/dd/yyyy and have it show up in the datasheet view with the slashes.
Edit:
I'm having the same problem with running times with an input mask 00:00:00.
Edit:
I found out that I can specify shortened versions of the DateTime datatype. That will do the trick. However, in the short term, is there a way to use an input mask and still have the delimiter come through?
As an absolute beginner to SAS I quickly ran into problems with date formatting.
I have a dataset containing transaction with three types of dates: BUSDATE, SPOTDATE, MATURITY. Each transaction is represented on two lines, and I want BUSDATE and SPOTDATE from line 1 but MATURITY from line 2.
In the original set, the dates are in YYYY-MM-DD format.
DATA masterdata;
SET sourcedata(rename(BUSDATE=BUSDATE2 SPOTDATE=SPOTDATE2 MATURITY=MATURITY2));
BUSDATE=BUSDATE2;
SPOTDATE=SPOTDATE2;
IF TRANS_TYPE='Swap' THEN;
MATURITY=SPOTDATE;
RUN;
Problem is, this returns something like 17169 (which I guess is the number of days from a certain date).
How can I make it output in YYYY-MM-DD format - or is this approach wrong; should I first convert the date variables to some SAS date format?
if you have valid SAS dates, just add a FORMAT statement to your DATA STEP.
Format busdate spotdate maturity yymmdd10. ;
SAS dates are numeric variables. They represent the number of days since 1/1/1960. You use a FORMAT to display dates.
Adding to CarolinaJay's answer, you normally want to keep them as numeric format, since you can do math (like "# of days since date X") with them. However, if for some reason you need a character variable, you can do this:
date_As_char=put(datevar,YYMMDD10.);
Incidentally, YYMMDD10 will actually give you YYYY-MM-DD, as you asked for; if you want a different separator, see http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000589916.htm (YYMMDDxw. format) - if you put a letter after the last D, for certain letters, you get a different separator. Like, YYMMDDn10. gives you no separator, or YYMMDDs10. gives you slashes. YYMMDDd10. gives you dashes, just like omitting the letter would. This concept also applies to MMDDYY formats, and I think a few others.
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.