I have a column in my database that is of type DATE.
I inserted the date via Java using the method: Date.valueOF(LocalDate.now()).
r.setRkd(Date.valueOf(LocalDate.now()));
The entry is correct because the exact date appears in the table.
rkd
------------
2022-03-02
The problem is that when I call the service I don't get the correct date back in the JSON, but a series of numbersenter code here.
"rkd": 1646175600000
Do you know how I can print the correct date in my JSON?
Thank you in advance.
That number you are getting is the milliseconds equivalent to the date you have stored. As far as I know, dates, in general, are stored as milliseconds and displayed in different formats, e.g. YYYY-MM-DD
If you need to display it in date format there should be a method to do it depending on the specific language that you're using.
Related
I'm using openweather 3hours forecast api. Why does the date show only the same time? even though values are different? date is supposed to be every three hours. I formatted the date in weatherItem.dart after iterating over each item.. how can I get the date with every three hours and render on the screen?
Looking at the JSON data you provided with the dt_txt key, you'll find that the date format does not contain time. So the JSON data you're getting does not contain a valid time you can use
I am building a Google Data Studio connector with a field called date. The field's type is YEAR_MONTH_DAY. Now, when I return a string, for instance "2020-09-22", the field shows null as a result. What value should my connector provide to have Data Studio recognize it as a date?
"2020-09-22" is of type YEAR-MONTH-DAY, not YEAR_MONTH_DAY
Without knowing the specifics of the connector you are using:
Be careful theat your provided format matches the expected one
Read about supported Dates and times in Data Studio
If necessary, use date formatting methods like e.g. TODATE
If the DATE field you are talking about is the absolute date as mentioned here, the expected format is YYYYMMDD.
For some reason I have had to implement a workaround for this more often lately which is to create a new field in the data source and use the TODATE() function and use that new field in my dimensions on the report.
Try a formula field like:
TODATE(comp_pd_end, "%Y-%m-%d", "%Y%m%d")
The expected date format for the connector is YYYYMMDD, without any separator.
You can check the official documentation:
https://developers.google.com/datastudio/connector/reference?hl=en#semantictype
I want to transform the value of fields name and Date using pentaho(kattle) and store it in standard format in any table.
For example
id,name,f_n,Date
1,j_vick,03-05-2015
2,jo_vick,04,08,2016
3,Arn_jonnn_vick,05,07,2017
Now I want to transform it using pentaho(kattle) IDE and store it in data base like below:
id,name,Date
1,john_vick,03/05/2015
2,john_vick,04/08/2016
3,Arn_john_vick,05/07/2017
I don't want the transformation steps concern with extraction database storage.
The date format is just some clothing of a value. Just read it with Kettle and store it as is. The database will store it in its proper internal binary format anyway.
Unless, you have to store them explicitly as varchar. In that case, use the Metadata tab of the Select Value step. Define your column as Date and specify the format as dd/MM/yyyy or MM/dd/yyyy. It will be kept internally as a Date, and converted into a String with the selected format at the last moment.
You also seam to have an other problem: the day, month and year are in three columns. The easiest way is to use a Modified Java Script Value step, in which you define a new column date = new Date(year, month, year), with type Date, and let Kettle handle with the format.
Maybe you have mixed input, in which case you can use a Filter or a Swtich step, based on weather you have something in the day and month column.
When that is done, you can make a job that runs the transformation on all the tables. You have an example in the sample/jobs/process all tables furnished with the Pentaho Data Integrator (aka Kettle).
I have a date column in my table, which will display a date as '17-MAR-15' format. Now I need to pass the date as 'DD-MM-YYYY(17-03-2015)' format to the Java API call. How can I pass this date parameter in that format?
You should take a look at: DATE_FORMAT
But basically what you do is this:
SELECT DATE_FORMAT(dateColumn, '%d-%m-%Y') FROM xyz;
Edit: Well, should have waited until I was really awake to answer, but if you happen to convert your date column to the date type this is how you would get the date in the specified format.
I have one problem in my tool. I am using one MySQL table called calendar. From this table I am fetching some date values. The format of date in calendar table is yyyy-mm-dd. But in my system having dd-mmm-yy. In my c# application I fetched the date from the Calendar and If I displayed the date in c# application means date format(2012-10-05) changed to system format(05-oct-12). But I need to display in yyyy-mm-dd format. I don't know how to solve this problem.
To display DateTime in specific format, you can specify the format in .ToString() method like:
DateTime dt = DateTime.Now; //your DateTime variable
Console.WriteLine(dt.ToString("yyyy-mm-ddd"));
You may see the article: Standard Date and Time Format Strings - MSDN