Recyclerview sort by current date - sorting

In the recyclerview, I have data in the format dd/MM/yyyy with a period titled date.I want this data to list only the dates that are less than the current date.I am using sqlite as database.

you should use ORDER BY in your sql request. And should format date in milliseconds before pass it into database. Then, when you called data in recycler view use SimpleDateFormat for formatting date into dd/mm/yyyy. For current date use Calendar.getInstance.getDateInMillis

Related

Changing format of date without using to_char - Oracle

I have to get the max payment date on an invoice and I am having trouble with the date format. I do not need the max in this formula as I am using the format in a reporting tool that is pulling the max from what it finds for me.
Using "to_char({datefield},'mm/dd/yyyy')" works for displaying that date the way we would like BUT when you use summary function MAX it does not pull the correct date because it is looking at a string and not a date (it will think 12/3/21 is larger than 3/2/22).
Another thing I have tried is trunc - "trunc({datefield})" which gives us the correct max date but it changes the formatting. For example if the date prior to the formula being applied is "8/12/21 12:00:00:000" the trunc formula will display it as 12-08-21 which is horribly wrong.
Long story short is I need a way to change a date/time to date with the format of 'mmmm/dd/yyyy' WITHOUT converting it to a string with something like to_char. Thank you!!!!
A DATE is a binary data type consisting of 7 bytes representing: century, year-of-century, month, day, hour, minute and second. It ALWAYS has all of those components and it is NEVER stored with any (human-readable) format.
What you are seeing when a date is displayed is the client application you are using to access the database making a decision to be helpful to you, the user, and display the binary DATE provided by the database in a human-readable format.
If you want to change how the DATE is displayed then you either need to:
Change the settings on the client application that controls how it formats dates when it displays them to you; or
Change the data-type so that it is no longer a DATE (which does not have a format) to a data type where the values of the date can be formatted (such as a string). You can do this using TO_CHAR.
If you want to find the maximum then do it BEFORE applying the formatting:
SELECT TO_CHAR(MAX({datefield}),'mm/dd/yyyy')
FROM your_table;

Can't remove hours and minutes from datatable

I'm trying to get release date field with y-m-d format.. Actually time format (for y-m-d) seems fine but also it gives h:m:s too, I changed time format at server side and removed h:m:s but datatable still shows them
What I get
2012-04-11 00:00:00
What I want
2012-04-11
Released_at field (Metronic theme - json datatable)
{
field: "released_at",
title: "Release Date",
type: "date",
format: "YYYY/MM/DD"
}
time format (I'm using laravel framework)
protected $dateFormat = "Y-m-d";
How do I fix this ?
Datatable accept column type same as mysql type.
You are trying to convert mysql dateTime column to Date in datatable, which is not possible from datatable.
In your code you have declared
format: "YYYY/MM/DD" // but actual type is dateTime as per mysql.So it will append time next to it.
If you are storing only date in mysql then you can change column type to Date, and your problem gets solved.
And if you want to convert string to date in laravel you can follow this post.
Your database column is of type dateTime which, by definition, includes both date and time information. If you want to remove the time at a database level then use the date type instead
$table->date("released_at")->nullable();
If instead of removing the time from the database, you just want to ignore it for certain parts of your application, you can leverage the fact than in Laravel all dates coming from your models are Carbon\Carbon instances, so you could do
$model->releasedAt->format('y-m-d'); // Returns '18-09-11'

Formatting a date column in powerpointwriter

I am using PowerpointWriter to populate a ppt table. I have currency and date columns that need to be formatted (not with colors/fonts/etc). For example, the date column needs to be the date only, not the time.
How do I do this?
Thanks,
Cheri
PowerPointWriter does not support that kind of formatting at the moment. You should consider formatting your data in your application before binding the data to the PowerPoint file using PowerPointWriter..

Filter by time and date in Hadoop

I have a table of data which have date and time as two separate field where date format is
dd/mm/yyyy and dd-mm-yyyy and time format is like hh:mm:ss(eg: 6:52:53)
i need to filter the record for a particular time period that both time and date wise filtering.
is there any predefined filter available with hive or pig?
Hive does recognize certain strings as unixtime dates.
You might try a where condition while concatenating the time & date together into unixtime format.
Some documentation on Hive date functions/formats are located here: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions
I suppose you have one column having two date format ie. dd/mm/yyyy and dd-mm-yyyy
What You can try
1) Replacing '/' to '-' so that complete column will be in dd-mm-yyyy format.
2) Try concatanating this field with time field
3) filter it by Casting concatinated field.
Hope this helps.
just possibility :- Have you tried casting that concatenated field to date datatype and then try date functions for desired output ?
eg. to_date()
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF

Hive dataype for date

Date;Time;Global_active_power;Global_reactive_power;Voltage;Global_intensity;Sub_metering_1;Sub_metering_2;Sub_metering_3
16/12/2008;17:24:00;4.216;0.418;234.840;18.400;0.000;1.000;17.000
16/12/2008;17:25:00;5.360;0.436;233.630;23.000;0.000;1.000;16.000
16/12/2008;17:26:00;5.374;0.498;233.290;23.000;0.000;2.000;17.000
16/12/2008;17:27:00;5.388;0.502;233.740;23.000;0.000;1.000;17.000
16/12/2008;17:28:00;3.666;0.528;235.680;15.800;0.000;1.000;17.000
16/12/2008;17:29:00;3.520;0.522;235.020;15.000;0.000;2.000;17.000
16/12/2008;17:30:00;3.702;0.520;235.090;15.800;0.000;1.000;17.000
16/12/2008;17:31:00;3.700;0.520;235.220;15.800;0.000;1.000;17.000
16/12/2008;17:32:00;3.668;0.510;233.990;15.800;0.000;1.000;17.000
This is the sample data, i am really confused with the datatype to be used for Date and Time.
plese help,
You probably want to be looking at the TimeStamp datatype which has this format:yyyy-mm-dd hh:mm:ss
There is also a Date datatype which takes this format: YYYY-­mm-­dd
There isn't a seperate time datatype. If you can't change the sample data you probably want to load the dates as string and use udfs like unix_timestamp(string date, string pattern) then copy to result into a new table.

Resources