Add days to a Date/time stored

Hello

Here's what I'm trying to do.

I am trying to add a field of records called #Warranty_Dump_Info.Reference # on a domain registration
called #Warranty_Dump_Info.Purchase_Date # and get a later date representing the date of expiry of a factory warranty.

#Warranty_Dump_Info.Reference # is a numeric value (30, 90, 180, etc.) that represents the number of days covered by the warranty and the #Warranty_Dump_Info.Purchase_Date # is the date/time value (example: 2009-01-01 00:00:00)

I can get the date/time format (time deleted).
with the help of < foutput > #dateformat(Warranty_Dump_Info.Purchase_Date, "mm-dd-yyy") # < / output >

However, I can't seem to add the number of days value of #Warranty_Dump_Info.Reference # or to display
in the right format of date (time stripped).

I tried the time of #Warranty_Dump_Info.Purchase_Date # stripping and then saving them as a variable, then
always using the Functionadds on the variable, but it fails to strip the time according to the results.

Thanks in advance for your help.


In addition, what it means when the date is displayed as follows: {ts ' 2009-01-01 00:00:00 '}
Some of my attempts to CF have resulted in this weird display "ts". You can see at the bottom of the page here: http://devo.dns2go.com/Warranty_Dump.cfm (logon as Admin, password: admin). That's where I tried to experiment and understand.

OK, now I see what you're saying...

I use CF functions in the SQL...

Here are the labour code for those who follow this thread:


SELECT *.
INNER JOIN Vendor_Table WARRANTY
ON Warranty.Vendor_Num = Vendor_Table.Vendor_Num
WHERE dateadd (would be ', Warranty_Days, Purchase_Date) > = Date)
AND Warranty.Part_Number ='#URLDecode (URL. "PartNumber) #
ORDER OF Part_Number, Serial_number CSA

Thank you very much for the help!

Eric

Tags: ColdFusion

Similar Questions

  • How can I add days to a Date value in a Script time?

    How can I add days to a Date value in a Script (XPATH) time?

    XPATH:

    Add Date:

    xs:dateTime($yourCurrentDateVar) + xs:dayTimeDuration($yourDuration)
    

    Difference in date:

    move "fn:days-from-duration(xs:dayTimeDuration(xs:date($yourCurrentDateVar) - xs:date($yourPrevDateVar)))" to $diff;
    

    You did not mention the version of the Framework, you can take advantage of the Business Service (BS) to perform Date calculations, for example, for FW2.2.x, you can use BS: C1-DateMath with such options as the 'Resistance' to add to the Date, "DIFF" for Date-Diff and FW4.x, you can use BS: F1-DateMath with options such as "F1AD" to add to the Date etc.

    Find out more about XPATH herefunction.

  • Add days to a date

    Hello world

    I am trying to add a (x) number of days to a date.

    example: 15-Aug-2011 + 6 = 21-sep-2011

    I tried several things with calendar, but didn't workout, suspicion

    Not a trivial exercise and don't forget that you can just add 24 * 60 * 60 * 1000 for one time to add 1 day, because the day could be a breakthrough in 'day '.  If you want only the day and not the time, so it's a little easier.  Here's a hat of suggestions, I think that will work for you.

    Take the date, convert it to a Calendar object, use DateTimeUtiltiies to ensure that the time is 0 (that is 12:00 midnight) get the delay in milliseconds of this calendar (get the Date, then get the shape of time this Date), adding n * DateTimeUtilities.ONEDAY, where n is the number of days that you want to add, and then add 12, ensure that move you in the "next day" without taking into account DST changes that could happen in the period , then put it in the calendar, zero once again, the time and do it.

    If it does not, show us the code that you have developed.

  • Add days to a date is to be indented by year.

    Hello

    I have the problem on Oracle 10 g. I have run the following statement that adds 1 to a date, but, unless I have format, the date is back with a year less than expected.
    SQL> select effective_date, (effective_date + interval '1' year(1)) as addyear, add_months(to_date(to_char(effective_date, 'MM/DD/YYYY HH24:MI:SS'), 'MM/DD/YYYY HH24:MI:SS'), 12) as addyearformat
       from price_change
            where
            price_change_id = '794328'   ;
    
    EFFECTIVE_DATE  ADDYEAR         ADDYEARFORMAT
    --------------- --------------- ---------------
    28-SEP-09       28-SEP-08       28-SEP-10
    Has anyone ever seen anything like that?

    Effective_date is of type date and has data in the format "MM/DD/YYYY HH24:MI:SS. I think it's something with the format, perhaps something to do with the zone - not sure. If I just insert a value into the table with the format ' MM/DD/YYYY HH24:MI:SS' I don't have this problem. I don't know how the date could have been modified to do that, but I know not to go through a time zone function before be inserted in this table, but I don't know if that is the cause of the problem.

    Don't know if it's important but nls_database_parameters...
    VALUE OF THE PARAMETER
    NLS_DATE_FORMAT dd-MON-rr
    NLS_TIMESTAMP_FORMAT-DD-MON-RR HH.MI. SSXFF AM
    NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI. SSXFF AM TZR
    NLS_TIME_FORMAT HH.MI. SSXFF AM
    NLS_TIME_TZ_FORMAT HH.MI. SSXFF AM TZR


    Thanks for any help in advance.

    Published by: amcgator on October 15, 2010 11:52

    amcgator wrote:
    In fact, this would explain why, if I do not pass the end of the year mark (IE if I just add 30 days), everything looks OK. How in the world that is possible, or how can I confirm this?

    Did you read my response? Question:

    select  to_char(effective_date,'mm/dd/yyyy bc')
      from  price_change
      where price_change_id = '794328'
    / 
    

    If you see bc - it's confirmed :).

    SY.

  • Add days to a date default of DateFields.

    I'm creating a DateField with default date and add to my screen. How can I create a second DateField and add three days to the current date and displays?

    Here is what it looks like when I open the screen initially:

    Here's what I want it to look like:

    Here is the code:

    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    DateField dateStart = new DateField("", 0, sdf, Field.FIELD_RIGHT
            | DrawStyle.RIGHT | Field.FOCUSABLE) {
        protected void layout(int width, int height) {
            super.layout(100, height);
        };
    };
    dateStart.setMargin(new XYEdges(0, 15, 0, 0));
    dateStart.setDate(Calendar.getInstance().getTime());
    dateArea.add(dateStart);
    
    DateField dateFinish = new DateField("", 0, sdf, Field.FIELD_RIGHT
            | DrawStyle.RIGHT | Field.FOCUSABLE) {
        protected void layout(int width, int height) {
            super.layout(100, height);
        };
    };
    dateFinish.setDate(Calendar.getInstance().getTime());
    

    Hello

    long ldate = System.currentTimeMillis();
    String date = new SimpleDateFormat("dd.MM.yyyy").format(new Date(ldate));
    

    Gets the current date as long in ldate and as a string to a date.

    If you want to add a day, simply add 24 * 3600 * 1000 to ldate. If you have the new date in milliseconds.

    just convert to e string trick.

    hope it helps

  • Add days to a date that a new release date?

    Hello everyone, I'm trying to figure out how to add the days since a specific date of entry to the output of a new date.

    For example, the user inserts the date in cell 1 and cell 2 will be released on what date is 3 days later.

    Row1Cell2 = Row1.Cell1 + (3 days).

    So for example, if I return June 26, 2012, the output would be 29 June 2012... or if I get 29 June 2012 the output would be July 2, 2012.

    What is the correct syntax to use to produce this result?

    You can put this script on the output of your Cell1 event (script is FormCalc):

    David var = Date2Num($,"YYYY-MM-DD")

    Cell2 = Num2Date (David + 3, "YYYY-MM-DD")

    The date format should take on any model to date you have set, but you may need to change the structure of date above to match what you need.

  • How to calculate the days with 2 Date/time fields

    Hello
    I tried to create a workflow to update a numeric field with the following formula, however, I get an error message "value too long for the field 'ZNum_0' (maximum size 16) (SBL-DAT-00235). Can I know what is the problem with my calculation?

    dtCloseDate - dtAssignDate

    Thank you

    Hi, your formula is correct.

    You could be facing this problem because it will assess the value in decimal and result has no set limit for the decimal point. As digital field accept only 16 characters, the problem is occure.

    You must truncate the result with a defined decimal.

    Hope this will help you
    Dinesh

  • Add days to date (integer format)

    Hi all

    I'm trying to add days to a date that is in numbers.

    Suppose I have a date 20140331 and if I add + 1 to her I me 20140332. How can I get 20140401 in digital format using pl/sql query.

    Also, I should be able to add any number of days existing dates to get the correct date. The example above is just a sample.

    Thank you

    Hello

    Here is an example showing how easy it is to use the arithmetic of dates with DATEs:

    CREATE TABLE table_x

    (x_id PRIMARY KEY NUMBER

    x_date DATE

    );

    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYYMMDD ';

    INSERT INTO table_x (x_id, x_date) VALUES (1, TO_DATE ('20140331', 'YYYYMMDD'));

    INSERT INTO table_x (x_id, x_date) VALUES (2, SYSDATE);

    SELECT x.*

    x_date + 1 tomorrow

    x_date + 10 AS ten_days

    FROM table_x x

    ORDER BY x_id;

    Output:

    X_ID X_DATE TOMORROW TEN_DAYS

    ---------- -------- -------- --------

    1 20140331 20140401 20140410

    2 20150219 20150220 20150301

    Date arithmetic is also easy and intuitive, when using the DATEs as a number arithmetic is using numbers.

  • How to add days, hours, minutes and seconds to a date?

    Hello

    I have the following problem.
    Saw 4 integers D, H, M, and S (each of them can be negative) and a date Da, I want to add days D, H hours, M minutes and seconds of S date Da.
    For example, if
    Da= to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss'), and D = 3, H = -2, M = 20 and S = -12, 
    This means that I want to add 3 days, -2 hours, 20 minutes and -12 seconds to the date Da, and the new date must be in the following date:
    to_date('01/07/2011 13:10:23','dd/mm/yyyy HH24:mi:ss') 
    Is it possible to write a query for this problem or should I use PL/SQL?

    Thank you.

    There is no need of PL/SQL

    SQL> alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS';
    
    Session altered.
    
    SQL> var d number
    SQL> var h number
    SQL> var m number
    SQL> var s number
    SQL> exec :d := 3; :h := -2; :m := 20; :s := -12
    
    PL/SQL procedure successfully completed.
    
    SQL> select to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss')
      2     + :d
      3     + (:h / 24)
      4     + (:m / 24 / 60)
      5     + (:s / 24 / 60 / 60)
      6  from dual;
    
    TO_DATE('28/06/2011
    -------------------
    01/07/2011 13:10:23
    
  • Day after posting today on the Date/time field

    I have a field on a form such as date. I try to validate the entry date, must in fact be a date AND equal or after today, otherwise stay on the ground until it is corrected.

    Use FormCalc for this, it is easier to do date arithmetic in this language. Follow these steps on the exit event of the field (i.e. the way the user has already chosen a date). There is a function called (Date2Num) which will be the date that went and convert the number of days since a specific time (called at the time). So you would have to number of todays het can get the number of the date, the user chose, and do a simple test to see if today's number is higher than the current one. Something like this:

    get the number for the selected date

    var selectedNum = Date2Num ($.rawValue "YYYY-MM-DD")

    the Date() function returns the number of days in the time to the current date (date system)

    If (selectedNum<= date())="">

    his previous... Inform the user

    xfa.host.messageBox ("Please enter a date later than today's date!")

    Place the cursor in the Date selection field

    xfa.host.setFocus ("DateTimeField1")

    endif

    This assumes that your Date selection field is called DateTimeField1

    Paul

  • How do I add 7 days to a date and compare it to the current date in a cfquery?

    I have classes that are no longer active once after the date of the class. However, the class should be displayed for seven days more in the backend. I tried to use the script below to get there, but I get an error "Variable DATE is not defined." I'm going in the right direction or is there a better way to do this?

    < name cfquery = "getClasses" datasource = "#application.dsn #" >

    Select *.

    (break the classReg INNER JOIN classReg.classID = classes.classID) INNER JOIN instructors ON classreg.instID = instructors.instID

    <!-adding seven days to the date of the class (date) by comparing the current date->

    where #DateFormat (DateAdd (would be ', 7, date), 'yyyy-mm-dd') # > #DateFormat (now (), 'yyyy-mm-dd') #.

    < / cfquery >

    where #DateFormat (DateAdd (would be ', 7, date), 'yyyy-mm-dd') # > #DateFormat (now (), 'yyyy-mm-dd') #.

    As Coldfusion said you, quite rightly so, he knows no variable called "date". You're in a request and, apparently, 'date' is a column name. So use the SQL functions instead of Coldfusion functions.

    In MySQL, the appropriate where clause is:

    WHERE DATE_ADD (date, INTERVAL of 7 DAYS) > CURDATE)

    In SQL Server, the appropriate where clause is:

    WHERE DATEADD(day,7,date) > GETDATE()

    ---------------------------------

    Afterthought: I would rename the column 'date', as it is a reserved word in some database management systems

  • I need to know the file current date/time number stamp and the version of "spoolsv.exe" in Vista Home Premium 32-bit with SP2.

    I need to know the file current date/time number stamp and the version of "spoolsv.exe" in Vista Home Premium 32-bit with SP2. My spooler file got corrupted and I need to know what that the stamp of date/time on the latest version of the file: spoolsv.exe. I did a search on my hard drive and found 8 copies of the file with 7 different dates. I need to know which copy in my file C:\windows\system32\. I suspect that the problem was caused by some kind of malware. I think that some of the different versions on my machine of the initial installation of the Vista, SP1 and SP2. 3 copies that would explain. I tried all the suggestions in this forum and several others. I tried sfc/scannow and it simply replaces the corrupted file by another. I understand how works this file and a simple copy will do the trick if I knew that the file to use. I know that I don't want to go back to the first version of 2006.  BTW... my symptoms are all my printers have disappeared, and when I try to 'add a new printer' I get an error message saying that my spooler service does not work. When I opened my services window it shows that indeed, he is arrested, but I will not start because the description column contains only the code garbled machine indicating that the file is corrupted, or it may contain a virus. I had been using F-Prot until this virus got by and now I use AVG. I scanned my machine with several cleaning packages and it is is more infected, but I worry that from this corrupt file grow something. I know that the problem is not with my printers or drivers, because everyone on my home network can print on all of my printers. None of the people I know are on Vista 32 bit. They are all running System 7 or XP. I have XP, except that a few years ago I suffered from the "Syndrome of Pepsi" on my laptop and when I bought a new HP, it came with Vista.

    Version 6.0.6002.18294

    Day 17/08/2010

    Duration 14:11

    Duration may vary in different time zones.

  • Problem with Capture Date &amp; time change

    I just became aware of a problem with the Date of Capture use to is very strange. Initially, a brief explanation of the import workflow I'm used with jpeg image 6 iPhone since Lightroom Mobile was presented. The images appear in the section of times iPhone app Photo, and from there I transfer to a collection in Lightroom Mobile. Once the collection syncs to Lightroom on my Mac (running latest El Capitan), they sort by capture time and I make choices and rename images. I have a naming preset that adds automatically the date to all the images. Recently, I noticed that some of these images, but not all, have been appointed with the wrong date. I had traveled without my computer - only my iPad, and it was a month before the images have been synced on my Mac it was very obvious that the dates were incorrect. The problem may have expressed earlier, but if the date was off by a day or two he would not have been as sensitive.

    The problem occurs when I take pictures with the app in time of MomentLens company. I use the application because it is designed to work with instant attachment lenses and the case of the Moment (which makes no difference in time to capture problem).


    Once that the images are added to LR Mobile news for images show good capture date and time. That's when they images sync for LR (latest version) that the problem occurs. And this is not a problem of LR Mobile, such as changes of date and hour occur if images of the iPad are added to LR without using mobile LR (from the iPad to Mac with AirDrop). Looking at the EXIF metadata Panel in LR, images taken with the iPhone camera app show three dates: Date time Original Date time digitized and Date time - all the which three are the same. Show only pictures taken with the application of the time Date time, but it's the same as in the iPhone Photo app and in LR Mobile capture time. However, when I show info on imagine in Lightroom, the time that appears to capture the time is the time that the image has been synchronized (if it came at LR Mobile) or the time that the image has been added to the iPad over wifi. It is also the time that is added to the preselection of naming. Note that if I send a picture directly from the iPhone to the Mac with AirDrop the date and time is correct.

    For the life of me, I can't understand this anomaly. I did thorough Imaging tests, and it happens only with the application of the time - other camera apps do not exhibit this problem. Interestingly, LR recognizes both the time Soft, which is reported under EXIF on the range of software and the lenses of the Moment when it is used with the iPhone the Moment case.

    If anyone has any ideas I'd be pleased to entrance. Thank you

    The link to the file is Dropbox - Photo of the Moment

    I have just confirmed with Exiftool that the sample file does not EXIF:DateTimeOriginal, although it does not contain EXIF:DateTime.

    You can send the following to the current time, the EXIF 2.3 specification:

  • Calculate the difference in days between two Dates

    Hello

    I'm trying to understand how to calculate the difference in days between two dates using JavaScript in LiveCycle. (Minimum = JavaScript knowledge)

    Where 'Start_Date' and 'Current_Date' are the names of the two dates in the palette of the hierarchy. (the two Date/time field)

    * Current date is using the object > value > execution property > current Date/time

    I need a text or number field showing the difference in days. (Difference_in_Days)

    I noticed the following code is pretty standard among other responses:

    var

    Start_date = new Date (Start_Date);

    var

    Current_Date = new Date (Current_Date);

    var

    nAgeMilliseconds = Current_Date.getTime) - Start_date.getTime ();

    var

    nMilliSecondsPerYear = 365 * 24 * 60 * 60 * 1000 ;

    I know there is lack of code and code above are may not be not correct.

    Please notify.

    OK, that's because of the way that javascript and works of the calculate event.  The field will be filled with whatever the script resolves at the end of execution. Technically, your script does not have a value because the last thing you do is an assignment to a variable.  Change the last line as follows:

    Math.ABS ((firstDate.getTime)

    ((- secondDate.getTime (()) / (oneDay));

    (eliminate the variable assignment) and get rid of the app.alert.  Your script will "return" (have) regardless of the value of calculation from the East and which will be stored in the field.

  • [8i] problem of calculation of Date/time...

    So I am currently faced with a situation where I need to calculate the total number of hours that a workstation is in use for each day in a given period. I have a table with newspaper each time that each workstation is used. The problem is a workstation can be used for any period of time, commencing on any day and ending on any day. This means that a particular log entry may extend over several days. I don't know how to split the difference between the time of the end of an entry and departure date/time of entry over several days.

    Here is a sample table and some sample data for what I'm doing:
    -- Note: in reality, this table contains more columns
    CREATE TABLE     my_hrs
    (     record_id     NUMBER     NOT NULL
    ,     sdatetime     DATE     
    ,     edatetime     DATE     
    ,     workstation     VARCHAR2(4)
         CONSTRAINT my_hrs_pk PRIMARY KEY (record_id)
    );
    
    -- Note: sdatetime, edatetime, and workstation CAN all be NULL, though I won't provide
    -- any sample data for these situations since I want to ignore them in my results
    -- Additionally, there are hundreds of workstations, but I'm only using 2 to simplify the sample data
    
    INSERT INTO     my_hrs
    VALUES (12345,TO_DATE('03/01/2010 08:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 13:35','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (13427,TO_DATE('03/01/2010 08:10','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 10:02','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (21543,TO_DATE('03/01/2010 14:07','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 16:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (22412,TO_DATE('03/01/2010 10:15','mm/dd/yyyy HH24:MI'),TO_DATE('03/01/2010 15:30','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (11976,TO_DATE('03/01/2010 17:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/02/2010 02:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (34215,TO_DATE('03/01/2010 22:10','mm/dd/yyyy HH24:MI'),TO_DATE('03/02/2010 04:30','mm/dd/yyyy HH24:MI'),'321B');
    INSERT INTO     my_hrs
    VALUES (24789,TO_DATE('03/02/2010 13:00','mm/dd/yyyy HH24:MI'),TO_DATE('03/05/2010 02:30','mm/dd/yyyy HH24:MI'),'123A');
    INSERT INTO     my_hrs
    VALUES (31542,TO_DATE('03/02/2010 21:30','mm/dd/yyyy HH24:MI'),TO_DATE('03/04/2010 10:30','mm/dd/yyyy HH24:MI'),'321B');
    According to my data in the example above, these are the results I want to see:
    WORKSTATION     DATE          HRS_IN_USE
    ------------------------------------------
    123A          3/1/2010     14.96667
    321B          3/1/2010     8.95000
    123A          3/2/2010     13.50000
    321B          3/2/2010     7.00000
    123A          3/3/2010     24.00000
    321B          3/3/2010     24.00000
    123A          3/4/2010     24.00000
    321B          3/4/2010     10.50000
    123A          3/5/2010     2.50000
    321B          3/5/2010     0.00000
    Is this possible? (Please note that if the workstation was not used on a particular day, I want to show him 0 for this workstation for that day). Another thing to note is that I work with Oracle 8i.

    Thanks in advance for the help!

    Hello

    user11033437 wrote:
    Sorry, bind variables are DATEs.

    Where are you running that? I assumed it was SQL * Plus, where the bind variable can not be DATEs.
    That's exactly why I wanted a full test case.

    user11033437 wrote:
    The WHERE clause is the culprit here.

    SELECT  p.min_date  + ROWNUM - 1      AS a_date
    ,     p.min_date + ROWNUM         AS next_date
    FROM     all_objects
    ,     (     -- Begin in-line view p to define parameters
              SELECT      :start_date  AS min_date
              ,      :end_date  AS max_date
              FROM      dual
         ) p     -- End in-line view p to define parameters
    -- WHERE     ROWNUM <= p.max_date + 1 - p.min_date --this is causing the error
    

    Published by: user11033437 on March 12, 2010 09:02
    Replaced the post with something SPECIFIC

    Thanks, I appreciate it.
    A surprising number of people on this forum does not seem to see the value of posting something specific. It's a great relief to work with someone who does.

    I said how I could not simply subtract two dates, t1d - T2D, in a place determined; I had to use TO_NUMBER (t1d - T2D). Maybe even workaround will be used here.

    user11033437 wrote:
    When I run the subquery p by itself and add a line to avoid the sdatetime of edatetime and look at the results, it seems that he could return the difference between two days of a type of INTERVAL data, rather than a number...

    SELECT      :start_date  AS min_date
              ,      :end_date  AS max_date
              ,      :end_date - :start_date AS my_int
              FROM      dual
    

    I discovered that if in the end I have will be querying this database and another, however the other database is Oracle 8i, 9i is obviously...

    sigh of frustration

    It may seem reasonable (at the time your conclusion and your frustration): intervals have been introduced in Oracle 9. (However, I noticed that sometimes "what's new" were actually available, although without papers, in earlier versions).
    Yet once again, how are the bind varibales defined? Looks like they are the timestamps. Subtracting two DATEs results in a NUMBER, but by subtracting two stamps produced an INTERVAL. You can change to the DATEs where they are defined?
    Try to use TO_DATE or CAST in the subquery p, to ensure that it produces DATEs:

    ,     (     -- Begin in-line view p to define parameters
              SELECT      CAST (:start_date AS DATE)  AS min_date
              ,      CAST (:end_date   AS DATE)  AS max_date
              FROM      dual
         ) p     -- End in-line view p to define parameters
    

Maybe you are looking for