Re: Getting a timestamp for today at midnight?

2018-11-16 Thread Mark Payne
Is that using the correct time zone? I.e., what if you print it out using:

DateFormat sdf = new SimpleDateFormat("/MM/dd HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println(sdf.format(new Date(myTimeAsLong)));

On Nov 16, 2018, at 4:16 PM, l vic 
mailto:lvic4...@gmail.com>> wrote:

That returns timestamp corresponding to 19:00PM
For example:
long myTimeAsLong=154232640L; // from NiFi
DateFormat sdf = new SimpleDateFormat("/MM/dd HH:mm:ss");
System.out.println(sdf.format(new Date(myTimeAsLong)));

prints out 2018/11/15 19:00:00

On Wed, Nov 14, 2018 at 9:21 AM Mark Payne 
mailto:marka...@hotmail.com>> wrote:
You should be able to do something like:

${now():divide( 8640 ):multiply( 8640)}

I.e., use integer division to divide by number of milliseconds in a day, which 
gives you
the number of days since epoch. Then multiply by 86,400,000 again to convert 
from
days back to milliseconds. While it looks immediately like it would do nothing, 
the thing
to keep in mind is that the divide() function performs and Integer Division 
operation,
not a Decimal Division, so all decimals would be dropped, which essentially 
results in
all hours/mins/seconds/milliseconds getting dropped.

Thanks
-Mark


> On Nov 14, 2018, at 9:01 AM, l vic 
> mailto:lvic4...@gmail.com>> wrote:
>
> I have to retrieve "today's" records in ExecuteSQL, eg. with the query using 
> timestamp "ts" column in table where ts type is "epoch" time as long integer :
> select * from mytable where ts >= midnight-timestamp-value
> Any idea how i can use "now()" function to get today's timestamp value at 
> midnight?
> Thank you,




Re: Getting a timestamp for today at midnight?

2018-11-16 Thread l vic
That returns timestamp corresponding to 19:00PM
For example:

*long* myTimeAsLong=154232640L; // from NiFi

DateFormat sdf = *new* SimpleDateFormat("/MM/dd HH:mm:ss");

System.*out*.println(sdf.format(*new* Date(myTimeAsLong)));


prints out 2018/11/15 19:00:00

On Wed, Nov 14, 2018 at 9:21 AM Mark Payne  wrote:

> You should be able to do something like:
>
> ${now():divide( 8640 ):multiply( 8640)}
>
> I.e., use integer division to divide by number of milliseconds in a day,
> which gives you
> the number of days since epoch. Then multiply by 86,400,000 again to
> convert from
> days back to milliseconds. While it looks immediately like it would do
> nothing, the thing
> to keep in mind is that the divide() function performs and Integer
> Division operation,
> not a Decimal Division, so all decimals would be dropped, which
> essentially results in
> all hours/mins/seconds/milliseconds getting dropped.
>
> Thanks
> -Mark
>
>
> > On Nov 14, 2018, at 9:01 AM, l vic  wrote:
> >
> > I have to retrieve "today's" records in ExecuteSQL, eg. with the query
> using timestamp "ts" column in table where ts type is "epoch" time as long
> integer :
> > select * from mytable where ts >= midnight-timestamp-value
> > Any idea how i can use "now()" function to get today's timestamp value
> at midnight?
> > Thank you,
>
>


Re: Getting a timestamp for today at midnight?

2018-11-14 Thread Mark Payne
You should be able to do something like:

${now():divide( 8640 ):multiply( 8640)}

I.e., use integer division to divide by number of milliseconds in a day, which 
gives you
the number of days since epoch. Then multiply by 86,400,000 again to convert 
from
days back to milliseconds. While it looks immediately like it would do nothing, 
the thing
to keep in mind is that the divide() function performs and Integer Division 
operation,
not a Decimal Division, so all decimals would be dropped, which essentially 
results in
all hours/mins/seconds/milliseconds getting dropped.

Thanks
-Mark


> On Nov 14, 2018, at 9:01 AM, l vic  wrote:
> 
> I have to retrieve "today's" records in ExecuteSQL, eg. with the query using 
> timestamp "ts" column in table where ts type is "epoch" time as long integer :
> select * from mytable where ts >= midnight-timestamp-value
> Any idea how i can use "now()" function to get today's timestamp value at 
> midnight?
> Thank you,