I use PostgreSQL 13.2, and try change lc_time parameter:
SET lc_time = 'ru_RU';
select set_config('lc_time', 'fr_FR', true);
But in both cases have this error:
[22023] ERROR: invalid value for parameter "lc_time": "ru_RU"
Then that locale is not supported by the C library on your operating system.
Related
i have this date of String type : 14-03-2019 and i need convert this in unix format.
this my code in javascript:
let time = moment(time).unix();
but moment response me with this error:
deprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments:
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: 14-03-2019, _f: undefined, _strict: undefined, _locale: [object Object]
Error
at Function.createFromInputFallback (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:320:98)
at configFromString (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:2368:15)
at configFromInput (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:2594:13)
at prepareConfig (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:2577:13)
at createFromConfig (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:2544:44)
at createLocalOrUTC (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:2631:16)
at createLocal (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:2635:16)
at hooks (/Users/Hernan/Haip/haip/node_modules/moment/moment.js:12:29)
at createTagChart (/Users/Hernan/Haip/haip/server/components/utils/index.js:36:18)
at Function.getInfluecerSearched (/Users/Hernan/Haip/haip/server/api/campaign-engine/campaign.model.js:439:39)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
and return a NAN
How can convert my string to unix format with moment ?
Since your date format does not follow the ISO_8601 format you need to provide the input date format to the moment constructor. In your case it appears to be 'DD-MM-YYYY' format and not one of the ISO date time formats, specifically just for date it would be YYYY-MM-DD.
So you need to provide the custom input format as the second argument to the moment constructor.
let time = moment(time, 'DD-MM-YYYY').unix(); // should output the correct value
However i suggest you should try to aim to get the source date-time to be in a standard ISO format than an arbitrary custom date format string as much as possible.
I have a client in Germany using an SSRS report and the date parameter is showing "OKT" instead we need it to be "OCT" for october
Is there a setting to make sure GETDATE() is already converted or will a convert function work?
here is my error:
library!ReportServer_0-45!1554!10/15/2018-10:23:17:: i INFO:
RenderForNewSession('/Finance/MC Dashboard')
processing!ReportServer_0-45!10bc!10/15/2018-10:23:17:: e ERROR:
Throwing
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
,
Microsoft.ReportingServices.ReportProcessing.ReportProcessingException:
Query execution failed for dataset 'JournalEntries'. --->
Microsoft.AnalysisServices.AdomdClient.AdomdErrorResponseException:
Query (5, 39) Cannot convert value 'Okt 14, 2018' of type Text to type
Date. at
Microsoft.AnalysisServices.AdomdClient.AdomdConnection.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.IExecuteProvider.ExecuteTabular(CommandBehavior
behavior, ICommandContentProvider contentProvider,
AdomdPropertyCollection commandProperties, IDataParameterCollection
parameters)
Since the GetDate is coming through in German from the server, then the SQL CONVERT function should also use German to convert it to a date.
CONVERT(DATETIME, GETDATE(), 106)
If you do get an error, you might need to set the language first (SET Language German;) - though that would be wonky that one SQL function would work in German but the other doesn't.
just capture the data first in a text box and check its format. Depending on how it looks you can worse case convert this receive input param to internal varchar and then just get the date part out. i.e.
declare #internal_param as varchar(15);
set #internal_param = #Input_dateParam --your variable name here
--select logic here
I've noticed that some users of my app are experiencing oddly formatted dates, and I am assuming it is due to locale reasons. Can someone suggest a better way to achieve the expected result and/or explain how to properly deal with the (possible) locale issue?
Time time = new Time();
time.setToNow();
String timeString = time.format("%b_%d_%Y_%I-%M-%S-%p");
Expected result:
Feb_12_2014_10-06-09-AM
From my logging I occasionally see results like this:
2?_12_2014_07-35-58-??
sadly I do not capture the locale info so I don't know the exact details.
edit: After trying the accepted solution here are the results for each locale on Android.
en_ca Feb_12_2014_10-49-52-AM
fr_CA févr._12_2014_10-49-52-AM
en_ca Feb_12_2014_10-49-52-AM
zh_CN 2?_12_2014_10-49-52-AM
zh 2?_12_2014_10-49-52-AM
en Feb_12_2014_10-49-52-AM
fr_FR févr._12_2014_10-49-52-AM
fr févr._12_2014_10-49-52-AM
de Feb._12_2014_10-49-52-AM
de_DE Feb._12_2014_10-49-52-AM
it_IT feb_12_2014_10-49-52-AM
ja 2?_12_2014_10-49-52-AM
ko_KR 2?_12_2014_10-49-52-??
ko 2?_12_2014_10-49-52-??
zh_CN 2?_12_2014_10-49-52-AM
<none> 2_12_2014_10-49-52-AM
zh_CN 2?_12_2014_10-49-52-AM
zh_TW 2?_12_2014_10-49-52-??
en_GB Feb_12_2014_10-49-52-AM
en_US Feb_12_2014_10-49-52-AM
Use a SimpleDateFormat to format your datetime strings. It has a constructor that allows you to specify the Locale, for example Locale.US.
Time.format() always works with the current, user-chosen locale which may not be what you want.
Further reading: Be wary of the default locale
I'm inserting a record into my DB using the following:
PreparedStatement stmt = null;
Connection conn = null;
HashMap<String, Object> hoursMap = new HashMap<String, Object>();
hoursMap.put("PLACE_ID", hours.getPlaceID());
hoursMap.put("DAY", hours.getDayID());
hoursMap.put("TIME_OPEN", hours.getTimeOpen());
hoursMap.put("TIME_CLOSE", hours.getTimeClose());
String insertStr = StatementCreator.insertQueryGenerator("HOURS",
hoursMap);
try {
conn = ConnectionManager.getConnection();
stmt = StatementCreator.createStatement(conn, insertStr, hoursMap,
false);
returnVal = stmt.execute();
ConnectionManager.closeStatement(stmt);
System.out.println("Created");
} catch (SQLException e) {
System.out.println("ERROR");
e.printStackTrace();
} finally {
ConnectionManager.closeConnection(conn);
}
return returnVal;
}
However, when running this I get the following error:
org.postgresql.util.PSQLException: ERROR: column "TIME_OPEN" is of
type time with time zone but expression is of type character varying
Hint: You will need to rewrite or cast the expression. Position: 71
What I can't figure out is why? The reason I say that is if I go into debug mode and look at the internal prepared statement I see the following:
INSERT INTO "HOURS" ("TIME_OPEN","DAY","TIME_CLOSE","PLACE_ID")VALUES('11:30:00-0400',6,'23:59:59-0400',541)
I copy/paste this into my SQL Editor and it runs and inserts the record.
Is there something I'm missing?
There is a subtle but decisive difference between a string literal and a variable of type varchar.
A string literal like '11:30:00-0400' has no type assigned to it. But your function obviously returns varchar, which is the same as '11:30:00-0400'::varchar.
Like the error message informs, you need to add an explicit cast in this case:
'11:30:00-0400'::varchar::timetz
Or, in your case probably:
hours.getTimeOpen())::timetz
(Not sure about the kind of syntax you use.)
Or have your function return the proper type to begin with.
Don't use timetz
As an aside, I would strongly advice against using time with timezone (timetz for short) at all. It's a logically broken type. Postgres only provides it for standard compatibility but advices against its use. I quote the manual here:
To address these difficulties, we recommend using date/time types that
contain both date and time when using time zones. We do not recommend
using the type time with time zone (though it is supported by
PostgreSQL for legacy applications and for compliance with the SQL standard)
And here:
The type time with time zone is defined by the SQL standard, but the
definition exhibits properties which lead to questionable usefulness.
In most cases, a combination of date, time, timestamp without time zone, and timestamp with time zone should provide a complete range of
date/time functionality required by any application.
If you only store the time+timezone, without the date part, you should declare the data type at PostgreSQL's side as timetz (or time with time zone) not timestamptz (or timestamp with time zone).
I am developing a site Zend based but I have the followin problem:
$currency = new Zend_Currency();
$currency->toCurrency(20, array('currency' => 'EUR','number_format' => '#0.#'));
Gives me 20,00 EUR but I need 20.00 EUR (that is why i set number_format), Any suggestion?
Try changing number_format to just format.
Excerpt from Zend_Currency Docs in reference to the options array('format' =>'#0.00'): format: Defines the format which
should be used for displaying numbers. This number-format includes for
example the thousand separator. You can either use a default format by
giving a locale identifier, or define the number-format manually. If
no format is set the locale from the Zend_Currency object will be
used.