paper-date-picker is working only when date is in quotes, as:
<paper-date-picker date='{{"some_data.date"}}'></paper-date-picker>
and this is not working:
<paper-date-pickerdate='{{some_data.date}}'></paper-date-picker>
What difference does the quotes make?
Value of some_data.date is string:
date: "2015-03-25"
The <paper-date-picker> date property seems to expect a new Date(...) instead of a string.
Related
I have a select query which has a date stored as string e.g. 20211231 (Dec 31, 2021). I am trying to use the CDate function to convert the string. If I enter the following in the SQL view
SELECT CDate(Format([XLCustOrdDtl]![DATE_ADDED],"####/##/##")) AS DteAdded
FROM XLCustOrdDtl;
The result are as expected, however when I go back to Design view and run the query, Access reformats the string to
SELECT CDate(Format([XLCustOrdDtl]![DATE_ADDED],"#\/#\/#")) AS DteAdded
FROM XLCustOrdDtl;
This results in #Error
Any thoughts on why this is happening and how I might correct the issue?
As your date is text, let Format know this and use #.
Also be aware, that to Format a slash is not a slash but the local date separator. To force a literal slash, escape it with a backslash:
SELECT CDate(Format([XLCustOrdDtl]![DATE_ADDED],"####\/##\/##")) AS DteAdded
FROM XLCustOrdDtl;
Apparently, lack of hyphen or slash punctuation in string means Access cannot recognize date parts and # is a date delimiter character and not valid as date format placeholder.
Assuming there are no Null fields and there are always 8 digits including placeholder zeroes, consider:
DateSerial(Left([DATE_ADDED],4), Mid([DATE_ADDED]5,2), Right([DATE_ADDED],2))
I have several things which I want to discuss with you guys.
Since, they were just simple questions, so no dataset here.
Suppose I have a datetime type column which called started_date, the value in it was like:
yyyy-mm-dd hh:mm:ss. So, if I want to select some IDs which were larger than one specified day (let's say June/01/2017), can I just using
select ID, started_date
from table1
where started_date>"2017-06-01";
Does this work?
I tried some samples, and it worked indeed in the mysql. However, someone told me that I cannot compare the datetime column with string values without converting their format. And it confused me. Because I thought the value "2017-06-01" here was date type value, so it does not need convert. Or am I thinking wrong?
Another thing was about the double quote and single quote, I understand that the single quote was used for string values. However, in this case, when I used double quote to quote "2017-06-01", it works. So, does it mean the double quote can quote date values?
I am just asking, so any response is welcome.
Thanks.
Your query is fine. You are using a safe date/time format for the string. In other words, if you have to store the value as a string, then use that format.
I would write the code as:
where started_date >= '2017-06-01'
I see no reason to exclude midnight on 2017-06-01 (although you might have a reason). Second, single quotes are the standard delimiter for strings.
That said, you can store the value as a string.
As a best practice, I stay away from comparing time-stamps to date-stamps. In this case you can be explicit and truncate the start date. And yes, use single quotes instead.
where SUBSTR(started_date, 1, 10) > '2017-06-01'
To make sure it works you could just convert the date time to a string first and compare the two strings:
to_char(started_date,'YYYY-MM-DD') >= '2017-06-01'
The Strings will compare just fine in that format.
We have a field in a query that should be left-padded with zeroes if it is too short, and we accomplish this using the Format() function. However, there are some values that produce bizarre results.
Format("14425112-8","00000000-00")
Returns the value "00019330-78"
For most inputs, the string gets formatted as expected, 8 digits, hyphen, two digits. But in a few rare cases, the value is modified. Is this repeatable for anyone else? Does anyone have an explanation?
Thanks for your help.
This is an example of access trying to be too helpful. It looks like it is interpreting these values as dates, but since you didn't use any date indicators in the format e.g: (dd,mm,yyyy), it converted 1-1 to a date, and then tried to display it in decimal form:
debug.print Format("1-1","000000-00")
returns 000427-36 which is the decimal value 42736 which, if you convert to a date, becomes 1/1/2017. This is what access interpreted "1-1" as.
it seems that access has reserved the - character as symbolizing a date format, despite what their website says. This function is only useful for formatting actual dates, or numeric values, such as prices. If you are set on using the format function, you will have to change you separator to a decimal point, which apparently is the only character that will get you what you want with the leading and trailing zeros.
Otherwise, you may have to build your own function for this.
You cannot format a string like a number this way. Try this:
PaddedNumber = Right(String(8, "0") & "14425112-8", 10)
I just started using webMETHODS today and need to transform a date input value that comes in like this.
Example:
yyyy-mm-dd hh:mm:ss:hh
I need just the date portion of this variable and am currently using pub.date:formatDate which will crash my flow service.
What should I be using?
An alternative would be to use pub.date:dateTimeFormat, which allows you to set an input pattern, for example dd.MM.yyyy hh:mm:ss.
pub.date:formatDate is used to convert a date input to a string output based on a string pattern.
Here you are trying to convert a string input to a string output.
You have to do the following:
a.
First convert the string (Process_date_orig_str) to date format (Process_date_dt)
b. Then use the date (Process_date_dt) to the required string format using pub.date:formatDate to get (Process_date_new_str)
Note: You will have to create your custom java service to convert string to Date.
I played around with this for practise. The 'correct' answer is what Christian Strempfer posted - this is what pub.date:dateTimeFormat is meant to do: transform beween datetime string formats. I'm not sure about your date pattern though - try currentPattern=yyyy-MM-dd HH:mm:ss.SS and newPattern=yyyy-MM-dd
A 'good hacky approach is using pub.string:subString (positions 0 and 10) to simply hack the end off the input string. You can also try regexs -- pub.string:replace, useRegex=true, searchString=^(.{10}).*, replaceString=$1. (searchString=^(.{10}) should also work, but it doesn't)
How can I extract the month with a sql query in mysql.
The date format is as follows: dd/mm/yyyy.
MONTH(datecol) = $month // this does not work.
However if I change the date format to yyyy-mm-dd it works, but this is not an option.
You can parse a date in any format into an SQL date value with str_to_date. For example:
select month(str_to_date('25/07/2013', '%d/%m/%Y'));
This expression will extract the portion of the string that appears between the first and second forward slashes.
SUBSTRING_INDEX(SUBSTRING_INDEX( '25/07/2013' ,'/',2),'/',-1)
will return '07'
To get this converted to a numeric, add zero to it,
SUBSTRING_INDEX(SUBSTRING_INDEX( '25/07/2013' ,'/',2),'/',-1) + 0
will return a numeric value of 7
NOTES
This expression will work with any string value, not just strings representing a valid date in the specified format. For example:
SUBSTRING_INDEX(SUBSTRING_INDEX( 'dd/mm/yyyy' ,'/',2),'/',-1)
will return 'mm'
If only one slash is found in the string, this will return the portion following the slash. If no slashes are found in the string, this will return the entire string.
If your intent is to validate that the string represents a valid date value, in the specified format, then the STR_TO_DATE() function can be used to convert the string to a DATE. The return from that expression can be used as an argument to any of the MySQL functions that take a DATE argument, such as the MONTH() function in your sample question.