Passing Current Date

How to pass current date into a query?

If you want the current date, you can get it using sysdate. If your field has no time component:

select PROC_PD_CD
from PS_PROC_PD
where PD_STRT_DT = trunc(sysdate);

Otherwise:

select PROC_PD_CD
from PS_PROC_PD
where PD_STRT_DT >= trunc(sysdate) and
PD_STRT_DT < trunc(sysdate + 1);

Adding current date to a method in YYYY-MM-DD

Yes, you can pass the current date in the method setSellingDate() without using any function.

use new Date() and
to set it to currentDate. you can use the following snippet,

import java.text.SimpleDateFormat
String currentDateString = new SimpleDateFormat('yyyy-MM-dd').format(new Date())

Docs: https://docs.oracle.com/javase/7/docs/api/java/util/Date.html#Date()

Display current date in dd/mm/yyyy format

Here's one way. You have to get the individual components from the date object (day, month & year) and then build and format the string however you wish.

n =  new Date();

y = n.getFullYear();

m = n.getMonth() + 1;

d = n.getDate();

document.getElementById("date").innerHTML = m + "/" + d + "/" + y;
<p id="date"></p>

Passing current date to the json with Karate dsl

2 suggestions.

Don't have a space after read and before the (.

Use Java to do date manipulation: https://stackoverflow.com/a/52892797/143475

How to make current date as the parameter instead of directly using it in postgresql?

As Laurenz Albe answered in the comment, I found the key of my issue is the type of @ReminderDay not the current date.

Here is the right sql:

SELECT * FROM A WHERE  etd:: DATE<=  @CurrentDate + @ReminderDay * INTERVAL '1 day'

And the parameters of this sql can be written as follow:

new {CurrentDate  = DateTime.Now, ReminderDay= 7 }

Pass a specific time with today's date as a value to the input field in Informatica Cloud

can you use this ?

to_char(sysdate,'MM/DD/YYYY') || '18:00:00.000000000'

Pls note this will produce a string.

If you want a datetime, pls convert this to datetime using to_date(above_st, format)

How to get the current date/time in Java

It depends on what form of date / time you want:

  • If you want the date / time as a single numeric value, then System.currentTimeMillis() gives you that, expressed as the number of milliseconds after the UNIX epoch (as a Java long). This value is a delta from a UTC time-point, and is independent of the local time-zone1.

  • If you want the date / time in a form that allows you to access the components (year, month, etc) numerically, you could use one of the following:

    • new Date() gives you a Date object initialized with the current date / time. The problem is that the Date API methods are mostly flawed ... and deprecated.

    • Calendar.getInstance() gives you a Calendar object initialized with the current date / time, using the default Locale and TimeZone. Other overloads allow you to use a specific Locale and/or TimeZone. Calendar works ... but the APIs are still cumbersome.

    • new org.joda.time.DateTime() gives you a Joda-time object initialized with the current date / time, using the default time zone and chronology. There are lots of other Joda alternatives ... too many to describe here. (But note that some people report that Joda time has performance issues.; e.g. https://stackoverflow.com/questions/6280829.)

    • in Java 8, calling java.time.LocalDateTime.now() and java.time.ZonedDateTime.now() will give you representations2 for the current date / time.

Prior to Java 8, most people who know about these things recommended Joda-time as having (by far) the best Java APIs for doing things involving time point and duration calculations.

With Java 8 and later, the standard java.time package is recommended. Joda time is now considered "obsolete", and the Joda maintainers are recommending that people migrate.3.


1 - System.currentTimeMillis() gives the "system" time. While it is normal practice for the system clock to be set to (nominal) UTC, there will be a difference (a delta) between the local UTC clock and true UTC. The size of the delta depends on how well (and how often) the system's clock is synced with UTC.

2 - Note that LocalDateTime doesn't include a time zone. As the javadoc says: "It cannot represent an instant on the time-line without additional information such as an offset or time-zone."
3 - Note: your Java 8 code won't break if you don't migrate, but the Joda codebase may eventually stop getting bug fixes and other patches. As of 2020-02, an official "end of life" for Joda has not been announced, and the Joda APIs have not been marked as Deprecated.

How can we pass current date-time to a angularjs function in a HTML page?

I'm trying my best to understand your question, but there's a lot of code to look through here. I do understand that you're trying to pass the current date to a function named "same-or-earlier than." However I can't seem to find a function with that name in your controller file.

I'm assuming that you've got a custom directive (attribute directive) that accepts the current date.

Either way, a simple solution for your problem of passing the current date could be to write a small function that when invoked returns the date using Javascript's native "Date" object.

Perhaps like this in your controller:

ctrl.returnCurDate = function() {
return new Date();
};

That way in your markup, you can invoke the method we've defined since it's attached to the scope of your controller.

same-or-earlier-than = "ctrl.returnCurDate()"

I hope I'm answering your problem in a relevant fashion, please feel free to ask further if I've misunderstood your question.

Best of luck.

P.S. Inherently there are some pain-in-the-butt formatting issues that come with using JS's native Date constructor, I would consider using a library such as "Moment.js" to relieve you of parsing the returned value when invoking:

new Date();


Related Topics



Leave a reply



Submit